你好,这是我的代码,任何人都可以建议我哪里错了,因为我得到了错误
select m.verify
CASE eore WHEN '1' THEN c.mobile from epmem m, empl c
WHEN '2' THEN c.gender from epmem m, comp c
ELSE NULL END,
as 'expose' where (c.rid=m.mid) order by mid desc limit 50
错误是
#1064 - Erreur de syntaxe près de
'CASE eore WHEN '1' THEN c.mobile
from epmem m, empl c WHEN '2' THEN c.gender fro' Ã la ligne 1
这就是我想要实现的目标 我想加入一个表与另一个表,其他表是动态的,将与案例值....
我想要的是,在案例1中加入empl和epmem,在案例2中加入epmem,并在代码中选择相关数据....
答案 0 :(得分:1)
每个CASE
语句都有END
SELECT m.verify,m.mid,
CASE eore
WHEN '1' THEN c.mobile
WHEN '2' THEN d.gender
ELSE NULL END AS 'expose'
FROM epmem m
INNER JOIN empl c ON c.rid = m.mid
INNER JOIN comp d ON d.rid = m.mid
ORDER BY m.mid DESC
LIMIT 50
编辑:
SELECT m.mid,m.email,m.eore,m.date,m.ipj,m.verify,
CASE eore WHEN '1' THEN d.mobile else c.gender END as expose1,
CASE eore WHEN '1' THEN d.profile else c.profile END as expose2,
CASE eore WHEN '1' THEN d.veri else c.mobile END as expose3
FROM epmem m
JOIN empl c ON c.rid = m.mid
JOIN comp d ON d.rid = m.mid
ORDER BY m.mid DESC
LIMIT 50