projectxmatt Posted May 22, 2007 Share Posted May 22, 2007 Ok im trying to return all results that come from or went to certain extensions on our phone logging system but i don't want to return any that have a src or dst that contain a * or a +. This is the where statement i have that is not working <?php WHERE src='3000' OR src='3001' OR src='3002' OR dst='3000' OR dst='3001' OR dst='3002' AND dst NOT LIKE '*%' AND src NOT LIKE '+%' AND dst NOT LIKE '+%' php?> Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/52494-solved-mysql-query-with-and/ Share on other sites More sharing options...
MadTechie Posted May 22, 2007 Share Posted May 22, 2007 your searching for src='3000' OR src='3001' OR src='3002' OR dst='3000' OR dst='3001' OR dst='3002' none of which contain + or * so why add the AND dst NOT LIKE '*%' AND src NOT LIKE '+%' AND dst NOT LIKE '+%' ? you could use AND (dst REGEXP (^[^*%]+$)) AND (src REGEXP (^[^*%]+$)) Quote Link to comment https://forums.phpfreaks.com/topic/52494-solved-mysql-query-with-and/#findComment-259030 Share on other sites More sharing options...
projectxmatt Posted May 22, 2007 Author Share Posted May 22, 2007 all those are searched for so if their is a src that was 3000 there can be a dst associated with it that is +12352332 or *97 and things like that. Which don't need to be returned. I tried what you provided to no success it errors out and returns the error [22/05/2007 11:01:43] MySQL: Invalid Query: SELECT COUNT(calldate) from cdr WHERE src='3000' OR src='3001' OR src='3002' OR dst='3000' OR dst='3001' OR dst='3002' AND (dst REGEXP (^[^*%]+$)) AND (src REGEXP (^[^*%]+$)) SQL error: 1064 (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '^[^*%]+$)) AND (src REGEXP (^[^*%]+$))' at line 1) Quote Link to comment https://forums.phpfreaks.com/topic/52494-solved-mysql-query-with-and/#findComment-259043 Share on other sites More sharing options...
MadTechie Posted May 22, 2007 Share Posted May 22, 2007 try <?php WHERE (src='3000' OR src='3001' OR src='3002' OR dst='3000' OR dst='3001' OR dst='3002') AND ((dst REGEXP '^[^*%]+$') AND (src REGEXP '^[^*%]+$')) php?> UPDATED: above Quote Link to comment https://forums.phpfreaks.com/topic/52494-solved-mysql-query-with-and/#findComment-259046 Share on other sites More sharing options...
projectxmatt Posted May 22, 2007 Author Share Posted May 22, 2007 that works partially. It eliminated the *'s from the src and dst but not the +'s from the src and dst. Thanks though i should be able to figure the rest out from there. Quote Link to comment https://forums.phpfreaks.com/topic/52494-solved-mysql-query-with-and/#findComment-259049 Share on other sites More sharing options...
MadTechie Posted May 22, 2007 Share Posted May 22, 2007 LOL Opps i omitted the % not + use ^[^*+]+$ <php WHERE (src='3000' OR src='3001' OR src='3002' OR dst='3000' OR dst='3001' OR dst='3002') AND ((dst REGEXP '^[^*+]+$') AND (src REGEXP '^[^*+]+$')) ?> Quote Link to comment https://forums.phpfreaks.com/topic/52494-solved-mysql-query-with-and/#findComment-259050 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.