随笔分类 -  SQL

摘要:https://www.cnblogs.com/monengji/p/11058242.html https://blog.csdn.net/z_atmosphere/article/details/82625058 阅读全文
posted @ 2020-05-18 16:19 那些年的代码 阅读(173) 评论(0) 推荐(0)
摘要:select count(c.channel_name),c.channel_name from channel c GROUP BY c.channel_name HAVING count(c.channel_name)!=1 阅读全文
posted @ 2020-04-27 08:10 那些年的代码 阅读(589) 评论(0) 推荐(0)
摘要:比如在Northwind数据库中有一个查询为SELECT c.CustomerId,CompanyName FROM Customers cWHERE EXISTS(SELECT OrderID FROM Orders o WHERE o.CustomerID=c.CustomerID) 这里面的E 阅读全文
posted @ 2019-12-05 10:41 那些年的代码 阅读(828) 评论(0) 推荐(0)
摘要:在做教务系统的时候,一个学生(alumni_info)有多个教育经历(alumni_education),使用的数据库是mysql,之前使用左链接查询的,发现数据量才只有几万条时,查询就很慢了,早上想到用子查询in,感觉效率还不是很高,结果想到用exists,效率高了很多。由于是第一次在mysql中 阅读全文
posted @ 2019-12-04 17:03 那些年的代码 阅读(11966) 评论(0) 推荐(1)
摘要:表展示 首先,查询中涉及到的两个表,一个user和一个order表,具体表的内容如下: user表: order表: in 确定给定的值是否与子查询或列表中的值相匹配。in在查询的时候,首先查询子查询的表,然后将内表和外表做一个笛卡尔积,然后按照条件进行筛选。所以相对内表比较小的时候,in的速度较快 阅读全文
posted @ 2019-12-04 17:00 那些年的代码 阅读(301) 评论(0) 推荐(0)
摘要:if @Select({"<script>", "SELECT " + " mu.id userId, " + " eui.id userInfoId, " + " mu.user_name userName, " + " com.company_id AS comId, " + " com.com 阅读全文
posted @ 2019-12-04 11:53 那些年的代码 阅读(3614) 评论(0) 推荐(0)
摘要:@Mapper public interface DemandCommentMapper extends BaseMapper<DemandComment>{ @Select("SELECT " + "a.id as 'id',a.create_date as 'createDate',a.cont 阅读全文
posted @ 2019-12-04 11:49 那些年的代码 阅读(3260) 评论(1) 推荐(0)
摘要:使用Statement执行查询语句的时候 : 比如要执行用户名 密码登录验证的sql语句 经常要输入 String sql = " select * from login where name=' " +name+ " ' and pwd = ' " +pwd+ " ' "; 这时候如果用户输入的密 阅读全文
posted @ 2019-06-11 17:22 那些年的代码 阅读(740) 评论(0) 推荐(0)