Mlungisi Ndlela
asked on
How to sort with a mysql column
Hi EE.
I have a query that retrieve data that has the provided word and this works well but now I want to sort this data when being retrieved based on a column name `lp` but I don't seem to be able to do so as if I add the Order by then the query seems not to return anything as the row is returned with 0. Below is the query code that I'm referring to here.
I'm using Mysqli.
I have a query that retrieve data that has the provided word and this works well but now I want to sort this data when being retrieved based on a column name `lp` but I don't seem to be able to do so as if I add the Order by then the query seems not to return anything as the row is returned with 0. Below is the query code that I'm referring to here.
$querrry = "SELECT * FROM `xxxxdatabase`.`xxxxtable` WHERE tags LIKE '%$searchq%' OR name LIKE '%$searchq%' OR category LIKE '%$searchq%' OR username LIKE '%$searchq%' OR addr2 LIKE '%$searchq%' OR city LIKE '%$searchq%' OR province LIKE '%$searchq' OR country LIKE '%$searchq%' OR company LIKE '%$searchq%' LIMIT 0,10 ORDER BY lp ASC " or die(mysqli_error());
$resultz = mysqli_query($conn, $querrry);
I'm using Mysqli.
hmm is that field Ip numeric ? Then try IsNum ... ORDER BY lp IsNum " or ....
ASKER
I've just tried that but still the row is returned with 0 which means there was no search.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Chris is right, MySQL is very picky about the order of the statements in a query.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.