如何从每一列中选择'r',而无需使用下表中的或函数

问题描述 投票:-3回答:1

表如下:

id    col1   col2    col3 
1      r       g     b
2      g       r     --
3      r        --    g
sql
1个回答
0
投票

尝试一下:

select * 
from test
where 'r' in (col1, col2, col3)

或此:

select * 
from test 
where col1 = 'r' or col2 = 'r' or col3 = 'r';

Here is the demo for Oracle.

© www.soinside.com 2019 - 2024. All rights reserved.