Jump to content

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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.