我試着顯示信息之前格式化我的所有數據在我的SQL增加的情況下statment到SQL連接語句
我的兩個連接的工作很好,我有一塊具有關聯的標題去與數據(狀態)的價值但CASE
陳述不起作用。我現在有做這個數據轉換PHP SWTICH聲明,但我想如果可能的話做,在SQL
SELECT
l.leadid, l.companyname, l.status, l.dateadded, addedby.name AS addedby, assignedto.name AS assignedto, l.address, l.city, l.prov, l.country, l.postalcode,
l.phone, l.fax, l.facebook, l.twitter, l.youtube, l.instagram, l.website, l.logo
FROM leads l
INNER JOIN staff addedby ON l.addedby = addedby.staffid
INNER JOIN staff assignedto ON l.assignedto = assignedto.staffid
CASE l.status
WHEN l.status = 7 THEN l.status = 'Converted'
WHEN l.status = 6 THEN l.status = 'Hot'
WHEN l.status = 5 THEN l.status = 'Warm'
WHEN l.status = 4 THEN l.status = 'Open'
WHEN l.status = 3 THEN l.status = 'NEW'
WHEN l.status = 2 THEN l.status = 'Cold'
ELSE l.status = 'Dead'
END
WHERE l.leadid = $id
它返回一個0,如果這是因爲該列被歸類爲一個INT,並即時更改爲字符? – user934902
@ user934902我認爲這個問題可能是每個THEN語句後的「l.status =」;只有那裏需要價值,試試我的第二種寫法,看看它是否有效。 –