Reputation: 399
I am searching columns A,B,C for the word 'hello'.
I want the results to be returned in order of columns being searched..
EG return all column a results, then column b, then column c.
is this possible? I am doing this currently.
SELECT * FROM `table` where table.A LIKE "%hello%" OR table.B LIKE "%hello%" OR table.C LIKE "%hello%"
Upvotes: 0
Views: 25
Reputation: 18747
Use UNION
:
SELECT * FROM `table` where A LIKE "%hello%"
UNION
SELECT * FROM `table` where B LIKE "%hello%"
UNION
SELECT * FROM `table` where C LIKE "%hello%"
Upvotes: 2