www.webdeveloper.com
Results 1 to 3 of 3

Thread: Query based on partial element

  1. #1
    Join Date
    Nov 2002
    Posts
    421

    Query based on partial element

    I would like to select rows based on the first character of an element. An easy example is a last name element. I would like to select all the rows where the name starts with "A".

    I know I could create another element with the one letter, but if there is a way to do this without changing the DB and updates that would be nice.

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    SELECT *
    FROM table
    WHERE lastName LIKE 'A%'

    % is a wildcard. If you wanted to get records where the last name has an A _anywhere_ in it, you would use LIKE '%A%'; if you wanted records where the last name ENDED with an A, you would use LIKE '%A'; the above example looks for last names that BEGIN with A.

    ^_^

  3. #3
    Join Date
    Nov 2002
    Posts
    421
    Perfect. Thank you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles