Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Order by substring? 1

Status
Not open for further replies.

elck

Programmer
Apr 19, 2004
176
NL
Is this at all possible in any way or form?
Code:
$query="SELECT title,id,date FROM `content` WHERE `user`='$user' ORDER BY SUBSTRING(title,(INSTR(title,';;')+2)) ASC ";
 
Thanks, it works too.
At first it didn't, hence my question, but the problems were spaces in front of the substring.

Now the code is even worse:
Code:
$query="SELECT title,id,date FROM `content` WHERE `user`='$user' ORDER BY TRIM(SUBSTRING(title,(INSTR(title,';;')+2))) ASC ";

Is this an efficient way, or should I grab all matches in a PHP array and perform the substr function there?

 
if you perform the substring in php, you will also have to sort the entire result set yourself, right?

let the database do it

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top