Jump to content

Recommended Posts

if($show->level == 2)
{
  $query = "select * from call_reminder WHERE (date >= '$todays_date' AND date <= '$max_date' AND level <= '$show->level') OR (member_group = '$show->mastermind' AND call = 'mastermind') ORDER by date, time";   
  $result_group = mysql_query($query) or die('Query failed: ' . mysql_error());
  echo $query;
}

On my echo I get :

[color=red]select * from call_reminder WHERE (date >= '2006-09-07' AND date <= '2006-10-22' AND level <= '2') OR (member_group = '1001' AND call = 'mastermind') ORDER by date, time [/color]

All values are correct, but the logic is not working. The dates work, the level works, but it is bringing up all 3 mastermind calls instead of just 1001's call.

I am at a loss here. Do I have too many variables in the query?

Snowdog
Link to comment
https://forums.phpfreaks.com/topic/20032-sql-query-issue/
Share on other sites

Remove the parenthesises from your query so its just this as the query:
[code]select * from call_reminder WHERE date >= '2006-09-07' AND date <= '2006-10-22' AND level <= '2'
OR member_group = '1001' AND call = 'mastermind' ORDER by date, time[/code]
Link to comment
https://forums.phpfreaks.com/topic/20032-sql-query-issue/#findComment-87875
Share on other sites

Well we could sit here all day guessing about your logic. All we know is what doesn't work.

Now if we knew what you had, and the records you expect to retieve from those, it might give us more of a clue so we can come up with the correct logic.
Link to comment
https://forums.phpfreaks.com/topic/20032-sql-query-issue/#findComment-87890
Share on other sites

Try this...

[code]
$query = "select * from call_reminder WHERE date(date) >= '$todays_date' AND date(date) <= '$max_date' AND level <= '$show->level') OR (member_group = '$show->mastermind' AND call = 'mastermind') ORDER by date, time";
[/code]

If that doesn't work, then post your code as previously suggested.

Rich
Link to comment
https://forums.phpfreaks.com/topic/20032-sql-query-issue/#findComment-87897
Share on other sites

OK I got it.

The first part of the logic was calling in the call that i wanted to only pull up by the mastermind number in the second half of the query.

So the calls I wanted to eliminate where already in the qiery and that is why the 3 calls came up when only one should have. So I fhad to eliminate the calls that I wanted to then run logic on in the second half of the query and it now works. Thanks all.

Here is the working query:

if($show->level == 2)
    {
      $query = "select * from call_reminder WHERE date >= '$todays_date' AND date <= '$max_date' AND level <= '$show->level' AND [color=red]member_group < 1000 [/color] OR member_group = '$show->mastermind' AND call = 'mastermind' ORDER by date, time";    
      $result_group = mysql_query($query) or die('Query failed: ' . mysql_error());
    }
Link to comment
https://forums.phpfreaks.com/topic/20032-sql-query-issue/#findComment-87902
Share on other sites

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.