How to select everything that starts with a...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

How to select everything that starts with a...

Post by GeXus »

Is there a function that will get the first character of a string in the database? I want to be able to select everything that starts with 'A', 'B', etc..

Thanks!
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Without dbms specific functions you can also select like 'A%'
Which dbms are you using? Mysql has a SUBSTRING function.

feyd | fixed link
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

mysql -> select * from table where field like 'a%'
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply