从多个表中选择

时间:2011-02-03 11:50:17

标签: mysql

我有表AA和列 值A B C

1,a,a

BBA,B,C,其值为2,b,b

如果我select B=a and C=a我希望将o / p作为具有值A的列1

如果我select B=b and C=b我希望获得值为A

的o / p列2

我想要单一查询

1 个答案:

答案 0 :(得分:2)

(SELECT a FROM AA WHERE B = 'something' AND C = 'something')
UNION ALL
(SELECT a FROM BB WHERE B = 'something' AND C = 'something')