Can any one help me how to sort rows by relevance for the following criterion ?
`tbluser`
- - - - - - -
First Name
Last Name
`tbleduc`
- - - - - - -
School
College
University
On the search form the user has following fields
Name
School
College
University
Where School College and University are Optional..
And Name is split into 2 words (other words in middle are omitted), first word is taken as first anme and last word as last name..
Now I would like to implement search based on relevance.
Thanks for the help 🙂
Okay, I tried this for you on Postgres (I don’t have MySQL here, so maybe it’s a little bit different):
I used these DDL statements to create the tables:
And a little bit of example data:
The query can be simplified a bit, if the relationship between
tbluserandtbleducis 1:1.Don’t forget to replace the
%a%,%b, … with your variables (I recommend using a prepared statement).I hope this template helps as a basic solution – you can tweak it as much as you like 🙂 You can also remove the outermost select statement, to get the counters of the individual results.