Page 1 of 1

[SOLVED] simple sql question

Posted: Thu Jan 01, 2004 3:27 pm
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.

Posted: Thu Jan 01, 2004 4:16 pm
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..

Posted: Fri Jan 02, 2004 5:49 pm
by mcog_esteban
thanks.