SQLScholar
Programmer
Hey all,
I am currently learning PHP. I have a website which i am making which has a mysql backend. I am currently creating a search. I have two little issues.
Firstly i have this code:
in the table "items" there are two records. If i run the above query i only get two records. If i remove all the "where" criterias - i get 6 (what i expect). Why am i only getting 2 results???
Secondly what i am trying to do is some kind of ranking system so that if the searched keyword is in the weblink field it appears higher in the search then in the metakeywords field and same with meta desc.
Now this should work.... however i have just thought that the results i want is actually the record shown with its highest rank. Because two or all three queries may come back with the same record, but i am only interested in the top one.
Any ideas?
TIA
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
I am currently learning PHP. I have a website which i am making which has a mysql backend. I am currently creating a search. I have two little issues.
Firstly i have this code:
Code:
SELECT weblink, metadesc, 1 as rank FROM items where weblink like '%[URL unfurl="true"]www%'[/URL]
union
SELECT weblink, metadesc, 2 FROM items where metakeywords like '%[URL unfurl="true"]www%'[/URL]
union
SELECT weblink, metadesc, 3 FROM items where metadesc like '%[URL unfurl="true"]www%'[/URL]
order by rank desc
in the table "items" there are two records. If i run the above query i only get two records. If i remove all the "where" criterias - i get 6 (what i expect). Why am i only getting 2 results???
Secondly what i am trying to do is some kind of ranking system so that if the searched keyword is in the weblink field it appears higher in the search then in the metakeywords field and same with meta desc.
Now this should work.... however i have just thought that the results i want is actually the record shown with its highest rank. Because two or all three queries may come back with the same record, but i am only interested in the top one.
Any ideas?
TIA
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------