简单的SQL格式

时间:2012-11-23 23:18:05

标签: mysql sql

任何人都可以帮我一个简单的sql标签吗?

这就是我想要的:

Select * from table1 where transid='select transid from table2 where date='01/02/2003''

如何以正确的sql格式使用它?

3 个答案:

答案 0 :(得分:5)

尝试:

Select * 
from table1 
where transid=(select transid from table2 where date='01/02/2003')

答案 1 :(得分:5)

Select * from table1
  where transid in 
    (select transid from table2 where date='01/02/2003')

答案 2 :(得分:4)

或者只是做一个JOIN

SELECT  table1.*
FROM    table1
JOIN    table2
ON      table1.transid=table2.transid
    AND date = '01/02/2003'