What I have is two tables inside of a mysql database.
One table contains the field with the value "example@example.com"
The other table does not…
What I would like to do is check both tables for a field with a value that matches "example@example.com".
Here is my query which does not work:
(#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 13)
SELECT CASE WHEN
EXISTS (
SELECT address, suburb, city, postCode, province
FROM user_postal
INNER JOIN user_info ON user_postal.id = user_info.id
WHERE user_info.emailContact = 'example@example.com'
)
OR EXISTS (
SELECT address, suburb, city, postCode, province
FROM user_postal
INNER JOIN user_business_info ON user_postal.id = user_business_info.id
WHERE user_business_info.emailContact = 'example@example.com'
)
I would like to return the values of the fields address, suburb, city, postCode, province that match the id of the user with the email example@example.com. (This could be in either of the two tables but it is surely in one or the other)
Could anyone enlighten me as to where I am going wrong with this? Any information in this regard would be greatly appreciated. Thanks!
How about this: