[SOLVED] simple sql question

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
mcog_esteban
Forum Contributor
Posts: 127
Joined: Tue Dec 30, 2003 3:28 pm

[SOLVED] simple sql question

Post by mcog_esteban »

hi...what's the right sql sentence if i would like to get all results of a table that begin with a peticular letter?
example : # A B C D E F ....., when i click on a letter i want all titles of books (example) that begins with an 'A'.
thanks.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

just use ORDER BY

Code: Select all

"SELECT books FROM mytable ORDER BY names";
if you want to do the letter thingie, try something like this :

Code: Select all

"Select books from mytable where title like '".$letter."'%' ORDER by books";
where $letter is the letter you click on..
mcog_esteban
Forum Contributor
Posts: 127
Joined: Tue Dec 30, 2003 3:28 pm

Post by mcog_esteban »

thanks.
Post Reply