Hi thanks

The code below:

SELECT *
FROM tbl_meddelregos m
JOIN tbl_mdconfregoptions r ON (m.confregoptionid = r.confregoptionid) WHERE
m.confregoptionid = 1
   OR m.confregoptionid = 6
   OR cocktailparty > 0
ORDER BY lastname

Provided the correct output.

Peter



-----Original Message-----
From: Peter Boughton [mailto:[EMAIL PROTECTED] 
Sent: Sunday, 11 March 2007 10:03 AM
To: CF-Talk
Subject: Re: SQL - slightly OT

You need brackets around the ORs, otherwise it'll only join correctly on the
first condition, and not the second two:

SELECT *
FROM tbl_meddelregos m, tbl_mdconfregoptions r
WHERE m.confregoptionid = r.confregoptionid
AND (m.confregoptionid = 1
     OR m.confregoptionid = 6
     OR cocktailparty > 0
    )
ORDER BY lastname


Alternatively, you could do it like this:

SELECT *
FROM tbl_meddelregos m
JOIN tbl_mdconfregoptions r ON (m.confregoptionid = r.confregoptionid) 
WHERE m.confregoptionid = 1
   OR m.confregoptionid = 6
   OR cocktailparty > 0
ORDER BY lastname




>I have some SQL which I am trying to get working
>
>Basically here is what I have:
>
>select *
>from tbl_meddelregos m, tbl_mdconfregoptions r
>where m.confregoptionid = r.confregoptionid and
>m.confregoptionid = 1 or
>m.confregoptionid = 6 or
>cocktailparty > 0
>order by lastname
>
>I keep on getting duplicate records in the output.
>
>Basically what I am trying to get
>
>I am joining 2 tables based on the confregoptionid (so as to get the code
to
>display for the registration option).
>
>I then want to display all records which are m.confregoptionid = 1
(standard
>registration), m.confregoptionid = 6 (early bird registration) and then
>those records where a person has paid to attend the cocktail part (as it
>wasn't included automatically in the registration fee paid.
>
>Thanks in advance for replies.
>
>P



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs
http://www.adobe.com/products/coldfusion/flex2/

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272296
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to