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 > select field starting with char

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-26-06, 17:07
ironCode ironCode is offline
Registered User
 
Join Date: Oct 2006
Posts: 12
select field starting with char

Ok because this forums search sucks (google should stay on google.com) i can't find anything with the search. I'm sure this is extremely easy.

What i'm trying to do is select all data (rows) that starts with a particular character.

For example i have the following table

id | data
1 | abc
2 | bcd
3 | zkb
4 | aht

now i need to pull all the fields containing the letter a (or A) as the first letter of the first word. I know how to do this in php but can't find anything for mysql. I believe i could user a wildcard char (%) in there but would that be the best way? it seems like that would put additional load on the server that isn't needed.

Any help would be great
Reply With Quote
  #2 (permalink)  
Old 10-26-06, 19:36
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
select ...
  from ...
 where left(data,1) = 'a'
__________________
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