Jump to content

SQL Query issue


snowdog

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