how to query the first 4 letters and the last 4 letters of field

Thread Solved

Join Date: Jul 2009
Posts: 128
Reputation: phpbeginners has a little shameless behaviour in the past 
Solved Threads: 16
phpbeginners phpbeginners is offline Offline
Junior Poster

how to query the first 4 letters and the last 4 letters of field

 
0
  #1
Aug 20th, 2009
Hi to all keen folks,

can you help me to query the first 4 letters and the last 4 letters in one field.

example: AAAABBBBCCCCDDDD how to query AAAA and DDDD.

thank you.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 141
Reputation: robothy is an unknown quantity at this point 
Solved Threads: 19
robothy robothy is offline Offline
Junior Poster

Re: how to query the first 4 letters and the last 4 letters of field

 
0
  #2
Aug 20th, 2009
Quickest option, although it isn't restricted to only four characters would be to:

  1. SELECT * FROM `example` WHERE `content` LIKE 'AAAA%' OR `content` LIKE '%DDDD';

For a more precise solution, I would look to use MySQL regular expressions.

Hope this helps,
R.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 128
Reputation: phpbeginners has a little shameless behaviour in the past 
Solved Threads: 16
phpbeginners phpbeginners is offline Offline
Junior Poster

Re: how to query the first 4 letters and the last 4 letters of field

 
0
  #3
Aug 20th, 2009
http://dev.mysql.com/doc/refman/5.0/...mmary-ref.html

I SOLVEd MY PROBLEM...thank you

use left and right :-)
Last edited by phpbeginners; Aug 20th, 2009 at 8:07 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 128
Reputation: phpbeginners has a little shameless behaviour in the past 
Solved Threads: 16
phpbeginners phpbeginners is offline Offline
Junior Poster

Re: how to query the first 4 letters and the last 4 letters of field

 
0
  #4
Aug 20th, 2009
in regexp like this

select myletters from testing_letters where myletters regexp '^AAAA' and myletter regexp 'DDDD$'

thank you
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 464 | Replies: 3
Thread Tools Search this Thread



Tag cloud for MySQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC