Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
mysql, ordering by a substring of a field
Old 07-10-2011, 09:16 AM mysql, ordering by a substring of a field
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
A table of mine has a field called title, which I want to order by. However, many of the titles (not all though) start with S*, i.e. S*AAA or S*BBB. When ordering I want to ignore the S* part, but since all titles does not start with S* I cannot simply remove the first two characters with the substring() function.

I'm basically looking for an SQL equivalent to php's ltrim($title, "S*")
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
 
Register now for full access!
Old 07-10-2011, 09:21 AM Re: mysql, ordering by a substring of a field
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
http://dev.mysql.com/doc/refman/5.0/...nction_replace

Code:
SELECT col FROM tbl ORDER BY replace(col, 'S*', '');
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 07-10-2011 at 09:23 AM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 07-10-2011, 01:03 PM Re: mysql, ordering by a substring of a field
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Ah, of course
Thanks!
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to mysql, ordering by a substring of a field
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23954 seconds with 12 queries