Jump to content

select distinct help pls


techker

Recommended Posts

hey guys i have this auto complete but it only selects one table..i need it to select 2?

 

SELECT distinct Nom as suggest FROM Etudiant WHERE Nom like('" .$search . "%') ORDER BY Nom

 

i need Nom and Prenom

 

i tryed Nom,prenom but did not work..

your query will weed out the duplicate values that are stored in the field "Nom", what exactly do you want your result set to be?

Link to comment
Share on other sites

in need the Nom and Prenom

 

first and last name.

 

i go this but it echos onlythe Nom(first name) and searches only half of the database

 

SELECT distinct Nom,Prenom as suggest FROM Etudiant WHERE Nom  like('" .$search . "%') And Prenom like('" .$search . "%') ORDER BY Nom

 

 

Link to comment
Share on other sites

but could it be that the distinct is faster?

the only reason it would be faster is because it is pulling less results, what you can do is limit the number of results that is returned using the limit keyword.

 

SELECT Nom,Prenom FROM Etudiant WHERE Nom  like '%$search%' OR Prenom like '%$search%' ORDER BY Nom LIMIT 100

Link to comment
Share on other sites

Hi

 

I take it this is for an Ajax call? You have a field where they type the name in and for each letter it does an Ajax call to bring back a list of possible matches?

 

If so the first thing I would suggest is to put in a short delay between people typing a letter and it doing the call back to the server. Doesn't need to be a long delay, but 1/4 of a second will stop repeated calls when someone is typing quickly. Ie, when they type a character you set up a Javascript timer to call a function for the ajax call. The first thing that function does is check if the input field contents are the same as they were when the timer was set up, and if not it abandons the Ajax call.

 

Once you do the call and check the database, 1000 rows isn't much to check and shouldn't take that long.

 

All the best

 

Keith

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.