I'm Andi,A software test Manager,over 8 years test work experience,like English and can speak in some certain situation ,if you are the guys who have the same work experience welcome here.

数据库

上一篇 / 下一篇  2017-03-20 19:04:41 / 个人分类:小知识点小结

发现以前基础比较扎实的数据库知识最近都忘记了,连最基本的SQL删除语句都忘记了,所以下定决心,痛定思痛,重新学习数据库!
 
 
1.左右连接的区别
 
Answer:
   左连接是已左边表中的数据为基准,若左表有数据右表没有数据,则显示左表中的数 据右表中的数据显示为空。
  左联接的结果集包括 LEFT 子句中指定的左表的所有行,而不仅仅是联接列所匹配的行。如果左表的某行在右表中没有匹配行,则在相关联的结果集行中右表的所有选择列表列均为空值。
  右联接是左向外联接的反向联接。将返回右表的所有行。如果右表的某行在左表中没有匹配行,则将为左表返回空值。
 
 
2.A表有而B表没有的数据。
Answer:
select * from A where field1 not in (select field1 from B)
如果比较多个字段
select * from A where not exists(select * from B where field1 = A.field1 and field2 = A.field2)
如果你的数据库支持except,还可以:
select field1, field2, ... from A
except
select field1, field2, ... from B
 
3.子查询
4.数据库里面的函数.
 

TAG: 数据库

 

评分:0

我来说两句

Open Toolbar