webForumDet fria alternativet

problem med null i mysql

2 svar · 328 visningar · startad av Vinnaren

VinnarenMedlem sedan sep. 2005858 inlägg
#1

Får inte följande att fungera:

SELECT CONCAT( u.firstName, ' ', u.lastName ) AS Name, p.title, p.date, p.leadTxt, p.bodyTxt, u.profileImage, 

(SELECT CASE lastupdate WHEN IS NULL THEN ' ' ELSE CONCAT('Uppdaterad', ' ', lastupdate) END AS 'lastupdate'
FROM edithistory AS eh 
WHERE eh.postID = p.postID 
ORDER BY lastupdate DESC 
LIMIT 1) AS lastupdate

AS lastupdate 
FROM post AS p 
INNER JOIN user AS u 
ON u.userID = p.userID

Får följande felmeddelande:
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 'IS NULL THEN ' ' ELSE CONCAT( 'Uppdaterad' , ' ' , lastupdate ) END AS 'lastupda' at line 1

Hur löser man detta med null??

Tacksam för all hjälp :stud

metalboyMedlem sedan jan. 2005870 inlägg
#2

Testa med

SELECT CASE WHEN lastupdate IS NULL THEN ' ' ELSE CONCAT('Uppdaterad', ' ', lastupdate) END AS lastupdate
VinnarenMedlem sedan sep. 2005858 inlägg
#3

tack, fungerar kanon

124 ms totalt · 3 externa anrop · cache AV · v20260731051352-full.56cc9887
0 ms — hämta statistik (cache)
0 ms — hämta forumlista (cache)
122 ms — hämta tråd, inlägg och bilagor (db)