Jump to content

[SOLVED] Mysql query with * and +


projectxmatt

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/52494-solved-mysql-query-with-and/
Share on other sites

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 (^[^*%]+$))

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.