1.inner join on, left join on, right join on详细使用方法
inner join(等值连接) 只返回两个表中联结字段相等的行
left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录
right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录
2.select 1 from table
1 select 1 from table;#显示列名为1、结果为1 2 select anycol(目的表集合中的任意一行) from table; -- (目的表集合中的任意一行) 3 select * from table
都是查看是否有记录,一般是作条件查询用的。但从效率上来说,1>anycol>*,因为不用查字典表。
3.把数据库dataA的表A的数据导入到数据库dataB的表B中:
情况1:dataB中没有B表
1 select * into dataB.dbo.B in dataB from dataA.dbo.B
情况2:A、B表结构不一样(指定字段) 2 insert into dataB.B(ID,NAME,PASSWORD) select ID,NAME,PASSWORD from dataA.A
情况3:结构一样 3 insert into dataB.B select * from dataA.A