php - help needed with mysql DISTINCT

114

I'm trying to get names out of a mysql table for an autocomplete (jquery ui). There are duplicate names and I don't want to show them in the suggestions. I also need to select other columns in the same query. is this possible? I'm using this query atm but there are still duplicate "s_name" returned..

SELECT DISTINCT s_name, s_time, s_auto, s_inout FROM testtable where s_name like '%" . mysql_real_escape_string($_GET['term']) . "%'
393

Answer

Solution:

DISTINCT will apply to the entire row - not just the column you stick it in front of. Could you just apply the filtering in PHP after obtaining the data from MySQL?

People are also looking for solutions to the problem: PHP JAVASCRIPT HTML, upload image upon BROWSE competion

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.