sql
雪兔0.0
这个作者很懒,什么都没留下…
展开
-
记录一次死锁(程序执行增删改卡死)
记录一次死锁(程序执行增删改卡死)原创 2022-07-11 14:38:14 · 103 阅读 · 0 评论 -
sql将数据横向展示
IF(expr1,expr2,expr3);当expr1为true时返回expr2,当expr2为false时返回expr3;重点:group by+if语句+聚合函数(max、sum)组合使用例如:表一为商品表 【product】product_idproduct_name1旺仔小馒头2旺仔QQ糖表二为商品明细表 【product_item】product_item_idunitunit_typepriceproduct_id1袋原创 2021-04-08 10:40:05 · 2546 阅读 · 0 评论 -
左连接(LEFT JOIN)无法返回主表所有行的解决方法
需求:在业务员管理客户页面,需要展示所有客户信息,并且按客户的最近下单次数进行排序。第一次写的代码如下<select id="queryHelpbuyCustomers" parameterType="Map" resultType="Map"> select a.addressId, a.shopName, a.phone, a.consignee, a.detailAddress, count(o.orderId) orderCount, (select ad原创 2020-10-13 12:00:41 · 2000 阅读 · 0 评论