Results 1 to 2 of 2
Jan 15, 2006, 23:30 #1
- Join Date
- Jan 2006
- 0 Post(s)
- 0 Thread(s)
Bring back all data, display subset first
I have an issue pulling back data the way I need it to come back...
Basically, I need to have all the data come back, but group certain data (based on a variable that is being written in PHP) and display it first.
So I have tried the following with no luck:
$select = "(select word,dates from sets where dates<=$time and ( word like '%".$photos."%' )) UNION ALL (select word,dates from sets where dates<=$time and ( word like '%site%' )) ORDER BY dates";
$select = "SELECT * FROM sets where dates<=$time GROUP BY( word like '%".$photos."%') LIMIT $sta,$show";
$select = "SELECT * GROUP_CONCAT(DISTINCT test_score ORDER BY test_score DESC SEPARATOR) FROM student GROUP BY '%".$photos."%';"
The last one is pieces of code I found out there...
The table structure is very straight forward.
dates setname keywords etc.....
So what I need is for *all* the data to come back, but the ones that match a specific search keyword (dynamically written in the sql line with PHP) should come back first.
So if I have a database of animals and someone searches "Gorilla" all the gorillas should come up first and then all the rest of the animals should be appended to the end of the result.
Any ideas? thanks again!!!
Jan 16, 2006, 03:15 #2
- Join Date
- Jan 2004
- Uppsala, sverige
- 2 Post(s)
- 1 Thread(s)
select * from sets order by case when keywords like '%$phpVariable%' then 0 else 1 end