SELECT nc.web_name AS company_name,
IF((b.booth_number LIKE '%Cafe%', b.booth_number, substring(b.booth_number,4)) AS booth_number,
nc.site_url AS website, IF (nc.ismi_status = 1, 'Member','') AS member_status
FROM booth_sale bs JOIN {ismi.booth} b ON bs.booth_id = b.booth_id
JOIN ismi.new_people np ON bs.contact_id = np.id
JOIN ismi.new_company nc ON nc.id = np.company_id
WHERE b.show_event_id = 298 AND status IN(44,45) ORDER BY 3
如果我这样做,查询工作正常:
IF((b.booth_number = 'Cafe', b.booth_number, substring(b.booth_number,4)) AS booth_number
PDOException:SQLSTATE[42000]:语法错误或访问冲突:1064
您的SQL语法有错误;查看手册
与您的MySQL服务器版本相对应,以便使用正确的语法
靠近AS booth_number,nc.site_url AS网站,IF(nc.ismi_status=1,
第2行的'Member','')':SELECT nc.web_name AS company_name,
IF((b.booth_number LIKE“%Cafe%”,b.booth_number,
子字符串(b.booth_number,4))AS booth_nnumber,nc.site_url AS网站,
如果(nc.ismi_status=1,'Member','')AS Member_status FROM
{ismi.booth_salel}bs加入{ismi.展位}b打开bs.booth_id=b.booth_id
加入{ismi.new_people}np ON bs.contact_id=np.id加入
{ismi.new_company}nc ON nc.id=np.company_id其中b.show_event_id=
298 AND status IN(44,45)ORDER BY 3(按3的顺序与状态)