我需要检索所有row_id,如果其中一个值为AST = 'undefined'
。
SELECT ROW_ID
FROM TABLE WHERE AST='unedefined'
不起作用。它只显示一行,但我希望获取具有相同ROW_ID
的所有行。
这是我的表:
<TABLE BORDER="1">
<TR> <TH>ROW_ID</TH> <TH>GENDER2</TH> <TH>RelNum</TH> <TH>Date</TH> <TH>VALUE</TH>
<TR> <TD>1</TD> <TD>M</TD> <TD>12</TD><TD>12/12/2014</TD><TD>undefined</TD>
<TR> <TD>1</TD> <TD>M</TD> <TD>12</TD><TD>13/12/2014</TD><TD></TD>
<TR> <TD>2</TD> <TD>M</TD> <TD>45</TD><TD>12/12/2014</TD><TD>54</TD>
<TR> <TD>3</TD> <TD>M</TD> <TD>56</TD><TD>13/23/2024</TD><TD>999</TD>
<TR> <TD>3</TD> <TD>M</TD> <TD>56</TD><TD>12/12/2014</TD><TD>undefined</TD>
</TABLE>
And I only want to see this in return:
<TABLE BORDER="1">
<TR> <TH>ROW_ID</TH> <TH>GENDER2</TH> <TH>RelNum</TH> <TH>Date</TH> <TH>VALUE</TH>
<TR> <TD>1</TD> <TD>M</TD> <TD>12</TD><TD>12/12/2014</TD><TD>undefined</TD>
<TR> <TD>1</TD> <TD>M</TD> <TD>12</TD><TD>13/12/2014</TD><TD></TD>
<TR> <TD>3</TD> <TD>M</TD> <TD>56</TD><TD>13/23/2024</TD><TD>999</TD>
<TR> <TD>3</TD> <TD>M</TD> <TD>56</TD><TD>12/12/2014</TD><TD>undefined</TD>
答案 0 :(得分:1)
select *
from table
where row_id in (
select row_id
from table
where ast = 'undefined')
答案 1 :(得分:0)
select *
from table t
where exists
(
select 1
from table t2
where t2.row_id = t.row_id
and t2.ast = 'undefined'
);