大家好,我有一个mssql 语句 
select a.id from t1 a, t2 b where a.id *= b.id我该怎样把它改写成mysql语句呢?感激不尽!

解决方案 »

  1.   

    select a.id from t1 a, t2 b where a.id = b.id
    直接原句就可以*=这个符号是你手误吧
      

  2.   

    to rucypli :
    不是手误,*= 作用是 当在b表中找不到a.id时 ,select 的结果 是a.id 而不是空。
      

  3.   

    嘿 是我解释错了 “当在b表中找不到a.id时”应该是 “当b表为空时”。
    来个mssql的例子
    create table table_a(id int)insert table_a(id) values(1)
    insert table_a(id) values(2)
    insert table_a(id) values(3)create table table_b(id int)select a.id from table_a a, table_b b where a.id*=b.id
      

  4.   

    我的本地竟然都执行报错,是08的运算符吗百度了下*= 是右连接 , 相当于 right outer join 
    =* 是左连接 , 相当于 left outer join
    select a.id
    from tb a right join tb b on a.id=b.id
      

  5.   

    SELECT * FROM A LEFT JOIN B ON A.ID=B.ID WHERE B.ID IS NULL
      

  6.   

    这个 *= 是ORACLE的LEFT JOIN语句, 在以前SQL2003未定义之前,很多数据库都有自己的语法来实现外连接。在SQL2003之后,则已经定义了LEFT JOIN,RIGHT JOIN这些标准。在MYSQL中采纳了SQL 2003标准。可以用
    select a.id from t1 a left join  t2 b on a.id = b.id
    自ORACLE9以后,同样的语法也被ORACLE支持。