dominod Posted September 8, 2010 Share Posted September 8, 2010 Hi ! I am trying this code: $query = "SELECT * FROM `table` WHERE name LIKE '%$keyword%' AND blocked != '%no%' ORDER BY hits DESC LIMIT 10 "; The 'blocked' row has the following value: "se dk no uk es" Now, what I want it to do is to NOT include that row IF it finds "no" in the blocked row... The problem is that it dont block it :/ It works if I dont use wildcard characters and the 'blocked' row = 'no' but I want to have multiple values in that row... Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/212882-why-wont-this-work/ Share on other sites More sharing options...
mikosiko Posted September 8, 2010 Share Posted September 8, 2010 maybe you can try $query = "SELECT * FROM `table` WHERE name LIKE '%$keyword%' AND LOCATE(' no ', blocked) = 0 ORDER BY hits DESC LIMIT 10 " if the 'no' is always in the middle of the string... wouldn't work if is in the borders. assuming that 'no' will be no part of other part of the string just use LOCATE('no', blocked) Quote Link to comment https://forums.phpfreaks.com/topic/212882-why-wont-this-work/#findComment-1108777 Share on other sites More sharing options...
dominod Posted September 8, 2010 Author Share Posted September 8, 2010 Solved it with AND blocked NOT LIKE '%no%' Thanks Quote Link to comment https://forums.phpfreaks.com/topic/212882-why-wont-this-work/#findComment-1108904 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.