Answered
help with an advance mysql query
I'm using CF 7 to query a MySQL 5 DB.
I was wondering if it's possible to add an OR operator in a subquery or at the end of a conditional statment. Let's say that in my conditional WHERE statement after a few inclusive conditions, I wanted to add an "AND & OR" logic.
maybe by including part of my code I can be a little more clear:
<cfquery name="domysearch" ...>
SELECT
a.id as id,
.....
b.company as company,
.....
c.add_line1 as add_line1,
.....
FROM registratn_contacts a, registratn b, registratn_addresses c
WHERE a.owner = #arguments.owner#
AND b.id = a.master_record
AND c.id = a.address_id
AND c.state = 'NY'
OR c.state = 'CA'
I would like to know if I can or should accomplish this in my query or if I should have this logic outside the query?
Thanks for any help!!!!
Carlos
I was wondering if it's possible to add an OR operator in a subquery or at the end of a conditional statment. Let's say that in my conditional WHERE statement after a few inclusive conditions, I wanted to add an "AND & OR" logic.
maybe by including part of my code I can be a little more clear:
<cfquery name="domysearch" ...>
SELECT
a.id as id,
.....
b.company as company,
.....
c.add_line1 as add_line1,
.....
FROM registratn_contacts a, registratn b, registratn_addresses c
WHERE a.owner = #arguments.owner#
AND b.id = a.master_record
AND c.id = a.address_id
AND c.state = 'NY'
OR c.state = 'CA'
I would like to know if I can or should accomplish this in my query or if I should have this logic outside the query?
Thanks for any help!!!!
Carlos