+ 1

Select distinct name, email from USER;

what should this command return ??.... is this possible to get distinct elements from both name and email tables of only from one .

30th Mar 2017, 7:43 PM
Vibhuti Narayan
Vibhuti Narayan - avatar
4 Answers
+ 5
Do you mean the distinct values of name, and then (separately) the distinct values of email? If so, you could two queries: select distinct name from users; and select distinct email from users; You could also join these results: select distinct 'resultset1' as a, name as b from users union select distinct 'resultset2' as a, email as b from users; I've added the constant strings 'resultset1' and 'resultset2' just for tracking purposes.
31st Mar 2017, 5:14 AM
Álvaro
+ 3
Oh Ok... "distinct" with a list of fields will return the distinct *combinations*. For example, two records that hold (each of them) name="n1" and email="e1" will be shown as one record in your result set.
31st Mar 2017, 5:37 AM
Álvaro
+ 1
I am also asking the same question ~~... if I am putting DISTINCT before two column name separated by " , " then what it will retrieve ....????.... as mentioned above ...
31st Mar 2017, 5:29 AM
Vibhuti Narayan
Vibhuti Narayan - avatar
+ 1
okk thanks...
31st Mar 2017, 5:40 AM
Vibhuti Narayan
Vibhuti Narayan - avatar