If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Newbie Help field manipulation.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-07-05, 11:45
mrwiegand mrwiegand is offline
Registered User
 
Join Date: Jan 2005
Posts: 2
Newbie Help field manipulation.

I am not sure how to technically explain this so please bear with me. I am trying to make a change where one of the columns has data that is returned from a query that puts two groups of numbers in it. Here is what the data looks like in the field.
ie:
12345 54321
ie2:
1234 54321
ie3:
1234 4321
the field name is client_id in table ups
So how do I get to remove all of the data and blanks left of the second group of numbers?
This example would be:
12345 54321
would be:
54321
or
12345 4321
would be:
4321

I thought of doing a this:
SELECT LEFT('XXXXX', 5);
but dont think this is correct first of all can you do a LEFT with wildcard?
Then I would just do a trim after that to remove the blank space.
Any suggestions would be greatly appreciated. And if this is right. Why is it not working?
Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 01-07-05, 22:31
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
what you do is find the space, and take everything to the right of that

the position of the space is given by LOCATE(' ',client_id)

then you take SUBSTRING(client_id,LOCATE(' ',client_id)+1)

voila
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On