按时间降序取第一条,将null替换为字符串


SELECT CONVERT(zhifubaoAccount,CHAR) as account,CONVERT(userTrueName,CHAR) as userName,CONVERT(money,CHAR) as cashMoney
FROM   log
where userId='567' ORDER BY createTime desc limit 1

 

 

误区:

SELECT CONVERT(zhifubaoAccount,CHAR) as account,CONVERT(userTrueName,CHAR) as userName,CONVERT(money,CHAR) as cashMoney
FROM   log 

where state =2
and createTime=(select max(createTime) FROM user_cash_log where userId='567')
and userId='567'

posted @ 2017-08-15 15:43  21heshang  阅读(193)  评论(0编辑  收藏  举报