Retrieve all fields starting with A for a table

Discussion in 'MySQL' started by quad_design, Mar 21, 2010.

  1. #1
    Hi,

    Is there a mysql statement which will allow me to pull all the fields starting with A from a table?

    Thanks in advance for any help.
     
    Last edited: Mar 21, 2010
    quad_design, Mar 21, 2010 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Something like:

    SELECT columns FROM my_table WHERE LEFT(column_name,1) = 'a';

    or

    SELECT columns FROM my_table WHERE LEFT(column_name,1) = 'A';

    If there are mixed cases you may need to use this. Try the first query before this one, as this would have slightly higher overhead.

    SELECT columns FROM my_table WHERE LOWER(LEFT(column_name,1)) = 'a';
     
    jestep, Mar 22, 2010 IP
  3. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #3
    SELECT [fieldname] WHERE [fieldname] LIKE 'A%';
     
    plog, Mar 22, 2010 IP