|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
There are rows in table having exactly identical field values. How to select only one of them by "SELECT" so that only one can be displayed.
|
|
#2
|
|||
|
|||
|
You need the DISTINCT keyword.
select distinct field_name ... |
|
#3
|
|||
|
|||
|
Thanks I tried with this. $result = MYSQL_QUERY("SELECT DISTINCT FROM $userstable WHERE ((name = '$name') And (location = '$location')) ORDER BY ID DESC"); It gives error. I do not know how to use DISTINCT in this case. Help appreciated. |
|
#4
|
|||
|
|||
|
It should be:
select distinct some_field from $usertable where name='$name' and location='$location' order by ID desc you must specify the field name(s) that you want to retrieve just like any other select, but the distinct keyword in front of the field name specifies not to return multiples of the same value in that field |
|
#5
|
|||
|
|||
|
Thanks a lot. It is working
|
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > SELECT statement problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|