PDA

View Full Version : combining LIKE & AND


tek
04-18-2006, 08:30 PM
I know about the LIKE command in (example) SELECT * FROM table WHERE name LIKE 'A%'

and I also know about the AND command, but combining them failed.

what I'm trying to get is to have 4 lists of names. (I have to enter all rows manually now (=> http://www.game-kings.com/speedgames.php ))
List 1 has all names that start with an A up to G,
2nd list is H - N,
3rd list is O - U
and the 4th list is for all names that start with a V up to the Z + all names that start with a number.

this would normally give me 4 MYSQL commands, wouldn't it? one for each list :)

vinyl-junkie
04-19-2006, 05:43 AM
Not necessarily. You could have a single query with an ORDER BY clause, then use a scripting language such as PHP to decide where to separate each list.

tek
04-20-2006, 08:03 PM
and, how would I do that?

trib4lmaniac
04-22-2006, 02:01 PM
SELECT * FROM `table` WHERE `name` REGEXP '^[A-G]'