日期:2014-05-16  浏览次数:20699 次

求一条查询语句
PHP code
两张表

表A:

product_id   user_id
1               12
2               12
3               13
4               13

表B:

product_id   owner_id
2               12
3               12
4               13
5               13

假设我要根据user_id=owner_id=12 来查询product_id, 最后要得到的结果是1,2,3,怎么做?


------解决方案--------------------
select product_id from A where user_id=12
union 
select product_id from B where owner_id=12