Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have make a table in sql. name of table is user.
which contain following field and data
name city state

pooja barmer rajasthan
ritu barmer rajasthan
pooja barmer rajasthan
ritu barmer rajasthan

i want result

name city state
pooja barmer rajasthan
ritu barmer rajasthan


that iwant to display only uniq record.if two or more records are same than select only 1 records.

please give me sql query for it?????????
Posted
Comments
[no name] 2-Jul-12 12:08pm    
Did you try SELECT DISTINCT?

1 solution

SQL
SELECT DISTINCT name, city, state FROM tbl

OR

SQL
SELECT name, city, state FROM tbl GROUP BY name, city, state
 
Share this answer
 
Comments
Ritu khatri 2-Jul-12 14:04pm    
if my table contain 8 or 10 fields than i write all fields name like this but it doesnot work
[no name] 2-Jul-12 14:19pm    
"it doesnot work" does not tell us anything about what does not work. Do you take your car to a mechanic and tell him that "it's broke" and he knows what you mean?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900