sort mysql query by filtered query
Posted
by kalpaitch
on Stack Overflow
See other posts from Stack Overflow
or by kalpaitch
Published on 2010-03-12T22:19:18Z
Indexed on
2010/03/12
22:27 UTC
Read the original article
Hit count: 747
I have two mysql queries:
$sql = "SELECT * FROM content WHERE threadName LIKE '%$filter%' ORDER BY lastUpdated desc";
and
$sql = "SELECT * FROM content ORDER BY lastUpdated desc";
The end result is to have all rows returned from a particular table 'content' but have those that match the variable $filter at the top. Is there either a single query that could combine these two or should I be using a JOIN?
© Stack Overflow or respective owner