下面有两个表分别查询出对应x的一天内的数据:表1.
x xx
1 a
2 aa
3 aaa表2.
y time yy
2 2009-12-01 08:20:33 0
1 2009-12-01 10:22:43 1
1 2009-12-01 11:18:30 0
3 2009-12-01 15:41:25 0
2 2009-12-02 17:52:33 1
3 2009-12-02 19:27:13 0
2 2009-12-02 20:39:05 1
2 2009-12-02 21:18:05 0我想得到的数据:x xx time yy
2 aa 2009-12-02 17:20:33 1
2 aa 2009-12-02 20:39:05 1
2 aa 2009-12-02 20:18:05 0请问用一条语句如何得出上面的结果 先谢谢了
x xx
1 a
2 aa
3 aaa表2.
y time yy
2 2009-12-01 08:20:33 0
1 2009-12-01 10:22:43 1
1 2009-12-01 11:18:30 0
3 2009-12-01 15:41:25 0
2 2009-12-02 17:52:33 1
3 2009-12-02 19:27:13 0
2 2009-12-02 20:39:05 1
2 2009-12-02 21:18:05 0我想得到的数据:x xx time yy
2 aa 2009-12-02 17:20:33 1
2 aa 2009-12-02 20:39:05 1
2 aa 2009-12-02 20:18:05 0请问用一条语句如何得出上面的结果 先谢谢了
from 表1 join 表2 on 表1.x=表2.y
where 表1.x=2
select 表1.x,表1.xx,表2.time,表2.yy
from 表1 join 表2 on 表1.x=表2.y
where 表1.x=2 and 表1.xx='aa'
这样不知道可以不?
from 表1 join 表2 on 表1.x=表2.y
where 表1.x=2 and 表2.time between '2009-12-02' and '2009-12-02 23:59:59'