我想从数据库表中选择值birthday。 如果它不为null,则输出应为日期。但如果它为null,则输出应为空。
'SELECT *,
case when isnull(mydate) then null else date_format(mydate, cats.bithday,"%d.%m.%y") end as birthday;
FROM cats
LEFT JOIN dogs ON cats.dogs=dogs.id'
我收到错误:
语法错误或访问冲突:1582参数计数不正确 对本机功能的调用' date_format'
答案 0 :(得分:2)
SELECT *, ifnull(cats.bithday,'') as cats_birthday
FROM cats
LEFT JOIN dogs ON cats.dogs=dogs.id
结果:
case (birthday is null)
cats_birthday = ''
case (birthday is not null)
cats_birthday = db-value
答案 1 :(得分:0)