The problem: I need to get values for X column with select statement, example:
People | X
————–
name1 | 1
name1 | 2
name1 | 3
name2 | 1
name2 | 2
name3 | 1
….
where people is unlimited count.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Update: Small feedback as summary of comments:
As Dave Costa and APC say, the results are non-deterministic. That is, if you run this query tomorow it is possible that first name1 to get id 2 in some conditions. However the query will still be correct.
If your table have attributes like DateInserted, DateOfBirth or other that can make a difference between same names, you can improve the query for example like this: