当我运行以下查询时,我会得到一个结果,但它看起来不正确。因此,其中某处肯定存在错误。
SELECT *
FROM fe_users
INNER JOIN user_managementsg_user_table AS umut ON
fe_users.uid = umut.fe_id
AND fe_users.city = 'Bern'
OR fe_users.city = 'Basel'
OR fe_users.city = 'Solothurn'
OR fe_users.city = 'Aargau'
AND umut.funktion = 'Assistenzarzt'
OR umut.fachgebiet_rheumatologie = 1
OR umut.taetigkeitsfeld = 'Praxis'
这就是我想要的:
fe_users.city
是Bern OR Basel或Solothurn OR Aargau
和
umut.funktion
是=' Assistenzarzt'或者umut.fachgebiet_rheumatologie
= 1或者umut.taetigkeitsfeld =' Praxis'
当我在上面运行查询时,列city
的某些值与我定义的4个城市不同。我的查询出了什么问题?
答案 0 :(得分:1)
SELECT * FROM fe_users
INNER JOIN user_managementsg_user_table AS umut
ON fe_users.uid = umut.fe_id
AND (fe_users.city in ('Bern','Basel','Solothurn','Aargau')
AND (umut.funktion = 'Assistenzarzt' OR umut.fachgebiet_rheumatologie = 1 OR umut.taetigkeitsfeld = 'Praxis')
答案 1 :(得分:1)
试试这个。
SELECT *
FROM fe_users
INNER JOIN user_managementsg_user_table AS umut ON fe_users.uid = umut.fe_id
Where fe_users.city IN('Bern'
,'Basel'
,'Solothurn'
, 'Aargau')
AND (umut.funktion in('Assistenzarzt') OR umut.fachgebiet_rheumatologie = 1 OR umut.taetigkeitsfeld = 'Praxis'))