CrustyDOD Posted April 12, 2008 Share Posted April 12, 2008 Hey! I have a question that is a bit more related to mysql then PHP so i hope i didn't miss the board too much. 1st Question: I have an array of english alphabet and a foreach loop that goes over array 1 by 1. Inside loop i have mysql query that searches for records (20 records per letter) that start with n letter ... LIKE 'A%' .... The question is how on earth do i get records that DO NOT start with alphabet letter? Basically before A output is done i would like to get 20 records that start with 0-9, _, -, etc ANYTHING but those 26 alphabet letters. Hope its clear 2nd question, doing the above method it means that i will have to execute 26 + 1 non-alphabet mysql queries (each query gets 20 records) (since they are inside loop). Is there any other way to do this without so many queries? Link to comment https://forums.phpfreaks.com/topic/100777-alphabet-loop-and-mysql-queries/ Share on other sites More sharing options...
marklarah Posted April 12, 2008 Share Posted April 12, 2008 "...WHERE `letter` != 'X'..." also use $i++; inside your loop somewhere to automate the ID or whatever. Link to comment https://forums.phpfreaks.com/topic/100777-alphabet-loop-and-mysql-queries/#findComment-515434 Share on other sites More sharing options...
CrustyDOD Posted April 12, 2008 Author Share Posted April 12, 2008 Yeah but that means that query will look like this: WHERE field NOT LIKE 'a%' AND field NOT LIKE 'b%' AND field NOT LIKE 'c%' ..all the way down to.. AND field NOT LIKE 'z%' That's a bit overkill isn't it? Link to comment https://forums.phpfreaks.com/topic/100777-alphabet-loop-and-mysql-queries/#findComment-515462 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.