Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL query question

Status
Not open for further replies.

LucL

Programmer
Jan 23, 2006
117
US
Say I have a query.

"SELECT * FROM content WHERE description=SOMETHING OR description LIKE %something%"

I want to have the top conditional list all results first and then the second conditional (since description=something will be more relevant). So, the first results should be all those where description=something, however many there may be, and then the second OR conditional.

Is there any way to do this without two seperate queries?

Thanks!
Luc L.
 
Code:
SELECT 
foo,
bar,
description
FROM content 
WHERE description='SOMETHING '
OR 
description LIKE %something%
order by
(case when description='SOMETHING' then 0 else 1 end)
 
very awesome. that worked perfectly. THANKS!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top