IT序号网

SQL用法笔记

shasha 2021年06月14日 数据库 333 0

1.更改当前记录以外的数据的xh自动加1(MySQL字段为int)
String sql = "UPDATE t_readtext as tr SET xh = xh +1\n" +"WHERE readcourceId <> "+ textbookId;
2.SQL CONCAT()函数作用是 返回的字符串参数连接的结果
工作的实例SQL代码如下
SELECT b1.displayname , b1.englishname , a1.ztsj , a1.textcns FROM ( SELECT cc.yhid, MAX(cc.yhda) as yhda , cc.ztsj, COUNT(cc.textbookid) textcns FROM ( SELECT a.yhid, MAX(a.yhda) as yhda , CONCAT(FLOOR(a.ztsj /86400) , '天', FLOOR((a.ztsj /86400-FLOOR(a.ztsj /86400)) *24) , '时', FLOOR(a.ztsj %3600/60) , '分' ) as ztsj, a.textbookid from t_yhzt a INNER JOIN t_xslgclass b on b.xsid = a.yhid WHERE b.bjid = 44 AND a.createdt>= DATE_SUB(CURDATE(),INTERVAL dayofyear(now())-1 DAY) GROUP BY a.yhid, a.textbookid)cc GROUP BY cc.yhid )a1 INNER JOIN t_yh b1 on b1.id = a1.yhid limit 2


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!