Here is what i'm trying to do using 1 SQL query (not sure if it's possible).
I want to display all objects matching a certain criteria (in this case a keyword) and then I want to display random results for the rest, BUT the data matching the criteria must be first, and then the random data.
This works, but doesn't have the random part...
SELECT * FROM content WHERE c_id <> 60 AND c_status="online" AND ((c_keywords="Corn Dog" OR c_keywords LIKE "%Corn%" OR c_keywords LIKE "%Dog%" ) OR length(c_keywords)>0) ORDER BY (case when c_keywords="Corn Dog" OR c_keywords LIKE "%Corn%" OR c_keywords LIKE "%Dog%" then 0 else 1 end) LIMIT 20
I tried adding a RAND() statement to the end but all I get is errors.
Thanks guys!
Luc L.
I want to display all objects matching a certain criteria (in this case a keyword) and then I want to display random results for the rest, BUT the data matching the criteria must be first, and then the random data.
This works, but doesn't have the random part...
SELECT * FROM content WHERE c_id <> 60 AND c_status="online" AND ((c_keywords="Corn Dog" OR c_keywords LIKE "%Corn%" OR c_keywords LIKE "%Dog%" ) OR length(c_keywords)>0) ORDER BY (case when c_keywords="Corn Dog" OR c_keywords LIKE "%Corn%" OR c_keywords LIKE "%Dog%" then 0 else 1 end) LIMIT 20
I tried adding a RAND() statement to the end but all I get is errors.
Thanks guys!
Luc L.