Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9053819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:31:23+00:00 2026-06-16T13:31:23+00:00

This statement SELECT * FROM TempTable t1 gives me this output: id idIndice valor

  • 0

This statement

SELECT * FROM TempTable t1 

gives me this output:

id  idIndice    valor
----------------------------
13  11          11111111
13  12          11111
14  11          11111111
14  12          11111
16  12          11111

Now with a little change:

SELECT * FROM TempTable t1
WHERE (select count(*) from TempTable t2 where t1.id = t2.id AND t1.valor != t2.valor) = 1

I get this

id  idIndice    valor
----------------------------
13  11          11111111
13  12          11111
14  11          11111111
14  12          11111

t1 and t2 are references to the same tempTable and I can understand t1.id = t2.id but this:

t1.valor != t2.valor 

is just too much for me. How come same columns as t1 and t2 are references for the same tables can be different?

And why this “= 1” at the end

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:31:24+00:00Added an answer on June 16, 2026 at 1:31 pm

    What the second query essentially does is “Select any rows for which the number of rows with the same ID and a different valor is 1” i.e. “Select any rows that have duplicate id’s“

    That is why both rows with id=13 are selected, as they are each others duplicate, and also why both rows for id=14 are selected.

    Note that if there are three rows with a same ID, none of them will be selected, because their number of duplicate id’s wont be 1, but 2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this SQL statement: SELECT * FROM history WHERE (fk_person = 2119) AND
If I use this statement: $query = select * from Products where category_description='.$search_dept.' ORDER
i use this statement for a single where condition ('SELECT * FROM users WHERE
I want to generate this SQL statement in LINQ: select * from Foo where
We have this statement: (SELECT res_bev.bev_id, property_value.name AS priority FROM res_bev, bev_property, property_value WHERE
I have a site with a SELECT statement like this: SELECT * FROM MyTable
This SQL statement SELECT `ip`, `when` FROM `metrics` WHERE `vidID` = '1' GROUP BY
After running this query statement with my database: select * from articles where content
I'm baffled as to what this SQL statement means: SELECT exhibitor_categories+0 from exhibitor_registry What
I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.