Speedy84 Posted October 18, 2008 Share Posted October 18, 2008 I've been trying to figure out why this doesn't work properly, but with no luck Issue: It sorts out everything from A to Y, but returns all entries starting with a Z. mysql_query("SELECT * FROM `artists` WHERE `name` NOT BETWEEN 'a%' AND 'z%' ORDER BY `name` ASC") Thanks in advance /Speedy Link to comment https://forums.phpfreaks.com/topic/128918-solved-5051a-not-between-issue-please-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 18, 2008 Share Posted October 18, 2008 The % wildcard only has meaning in a LIKE statement. The way you are using it means everything greater or equal to the string "a%" and everything leas than or equal the string "z%". Well "za...", "zb..."... are all greater than the string "z%", which is why they show up in the result set. Link to comment https://forums.phpfreaks.com/topic/128918-solved-5051a-not-between-issue-please-help/#findComment-668412 Share on other sites More sharing options...
Speedy84 Posted October 18, 2008 Author Share Posted October 18, 2008 hmm.. i just removed the % on both A and Z.. but it still returns the same result as before ??? Link to comment https://forums.phpfreaks.com/topic/128918-solved-5051a-not-between-issue-please-help/#findComment-668415 Share on other sites More sharing options...
PFMaBiSmAd Posted October 18, 2008 Share Posted October 18, 2008 That is because "z-anything" is greater than "z-null" It appears you want to select names that begin with anything other than a letter? This should work (untested) - mysql_query("SELECT * FROM `artists` WHERE LOWER(LEFT(`name`, 1)) NOT BETWEEN 'a' AND 'z' ORDER BY `name` ASC") Link to comment https://forums.phpfreaks.com/topic/128918-solved-5051a-not-between-issue-please-help/#findComment-668427 Share on other sites More sharing options...
Speedy84 Posted October 18, 2008 Author Share Posted October 18, 2008 that works just perfect! thank you Link to comment https://forums.phpfreaks.com/topic/128918-solved-5051a-not-between-issue-please-help/#findComment-668432 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.