我拥有的是 mysql 数据库中的两个表。
一个表包含具有值的字段"example@example.com"
另一张桌子没有...
我想做的是检查两个表中是否有一个值匹配的字段"example@example.com"
。
这是我的查询不起作用:
(#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'
)
我想返回与address, suburb, city, postCode, province
用户 id 和 email 匹配的字段的值example@example.com
。(这可能在两个表中的任何一个中,但肯定在一个或另一个中)
谁能告诉我我哪里出了问题?任何这方面的信息将不胜感激。谢谢!