一.
1.查詢出訂單id最大的那條記錄
select user_id,order_id from loan_order_base where user_id = 348 order by order_id desc limit 1
2.limit i,n
i:為查詢結(jié)果的索引值(默認(rèn)從0開(kāi)始)酌呆,當(dāng)i=0時(shí)可省略i
n:為查詢結(jié)果返回的數(shù)量
3.多行數(shù)據(jù)合并
select GROUP_CONCAT(DISTINCT user_id SEPARATOR ',') from user_device where did ='0452e9933dce0c38'
4.order_id =206 訂單id為106的記錄有多條轨蛤,現(xiàn)在要更新訂單id為106的最新一條記錄的repay_amount字段的值澈蝙,寫(xiě)法如下:
update loan_code_log set repay_amount=19 where order_id =206 order by id desc limit 1
二.
- where 1 = 1 條件的妙用
三. MySql中count(*)和count(字段)的區(qū)別
詳解: https://blog.csdn.net/qq_38089964/article/details/80872657