views:

107

answers:

1

hello, how can I Select and dont'show duplicates? actually it's showing like that: apple | apple | apples | apple

this is my code:

$search = $_GET['q'];
$query = "SELECT * FROM query WHERE searchquery LIKE '%$search%' AND searchquery <> '$search'"; 
+3  A: 

You already said the magic word: DISTINCT.

SELECT DISTINCT columnname
FROM query
WHERE ....

Note that it probably won't work if you use SELECT DISTINCT * because when you select * that means select all columns, including columns which have a unique constraint such as the primary key. Only select the columns you need - stay away from * in general, and especially so when using DISTINCT.

Mark Byers
very cool! thank you!!
elmaso