Jump to content

SQL Query Not Returning Preffered Results


elabuwa

Recommended Posts

Hello guys,

 

Can some one shed some light on why the below query is returning the wrong results.  :'( :'(

 

SELECT campaign_details.pid,campaign_summary.uid,campaign_summary.customer_id FROM campaign_summary,campaign_details WHERE campaign_summary.camp_id=campaign_details.camp_id AND campaign_summary.uid='1' OR campaign_summary.uid='11' AND [b]campaign_summary.customer_id='205'[/b] AND [b]campaign_details.pid='7'[/b] GROUP BY campaign_details.pid

 

I am explicitly telling stupid sql to return only where the campaign_details.pid matches with 7 and campaign_summary.customer_id matches with 205.

But I get the below result set.

pid----uid---customer_id

1------1-----65

2------1-----84

4------1-----81

5------1-----63

7------1-----65

13-----1-----63

 

Why is it returning PID's other than 7?

Why is it returning customer_id's other than 205?

There should be no results at all.

 

Can someone please shed some light?

Mysql server v5.0.51

 

Any help is greatly appreciated

Link to comment
Share on other sites

Parenthesis..  and... numbers are not strings.. so no need for quotes.

SELECT campaign_details.pid,campaign_summary.uid,campaign_summary.customer_id 
FROM campaign_summary,campaign_details 
WHERE (campaign_summary.camp_id=campaign_details.camp_id) 
    AND (
            campaign_summary.uid=1 
            OR campaign_summary.uid=11
            OR campaign_summary.customer_id=205 
            OR campaign_details.pid=7
            )
    GROUP BY campaign_details.pid1

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.