您现在的位置是:首页 > 数据库数据库
mysql常用查询
2021-05-19 14:22:37【数据库】人已围观
简介多表联合查询
订单表,用户表,时间格式,datetime
时间格式,int unix时间戳
多表联合查询
订单表,用户表,
订单表,用户表,GROUP_CONCAT(b.order_id) AS order_id,按照user_level字段分组GROUP BY ,HAVING COUNT分组大于3
时间格式,datetime
时间格式,int unix时间戳
订单表,用户表,
SELECT FROM_UNIXTIME(order_create_time,'%Y-%m-%d') AS order_create_time,a.user_id,a.goods_id,a.order_class,a.order_amount,a.order_bv,b.user_grade,b.user_level,b.user_parent_id,a.user_directseller_id FROM order a LEFT JOIN user_base b ON a.user_id=b.user_id WHERE FROM_UNIXTIME(order_create_time,'%Y-%m-%d')='2021-04-19' ORDER BY b.user_level DESC多表联合查询
订单表,用户表,GROUP_CONCAT(b.order_id) AS order_id,按照user_level字段分组GROUP BY ,HAVING COUNT分组大于3
SELECT a.regtime,b.order_bv,b.user_directseller_id,GROUP_CONCAT(b.order_id) AS order_id FROM user_base a LEFT JOIN order b ON a.user_id=b.user_directseller_id WHERE a.user_grade='3' AND a.regtime>'1618813834' AND b.t31_s='0' GROUP BY b.user_level HAVING COUNT(*)>=3
时间格式,datetime
SELECT * FROM `order_base` WHERE DATE_FORMAT(order_create_time,'%Y-%m')='2021-03'
时间格式,int unix时间戳
SELECT * FROM `order_base` WHERE FROM_UNIXTIME(order_create_time,'%Y-%m')='2021-03'
很赞哦! ()
下一篇:mysql update
相关文章
-
无相关信息