ITeye博客

sql

共 2 篇文章

sql(join中on与where区别)

原文地址: http://zzstudy.offcn.com/archives/2146 left join :左连接,返回左表中所有的记录以及右表中连接字段相等的记录。 right join :右连接,返回右表中所有的记录以及左表中连接字段相等的记录。 inner join: 内连接,又叫等值连接,只返回两个表中连接字段相等的行。 full join:外连接,返回两个表中的行:left join + right join。 cross join:结果是笛卡尔积,就是第一个表的行数乘以第二个表的行数。 关键字: on 数据库在通过连接两张或多张表来返回记录时,都会生成一张中间的临时表,然后再…

2014-08-17 23:44 · sql

SQL for update

1 select * from TTable1 for update 锁定表的所有行,只能读不能写 2 select * from TTable1 where pkid = 1 for update 只锁定pkid=1的行 3 select * from Table1 a join Table2 b on a.pkid=b.pkid for update 锁定两个表的所有记录 4 select * from Table1 a join Table2 b on a.pkid=b.pkid where a.pkid = 10 for update 锁定两个表的中满足条件的行 5. select …

2014-06-16 17:36 · sql