如何获得结果并指定下一个

时间:2015-11-12 02:07:14

标签: sql

1)

SELECT A.SSID FROM T_TABLE_1 A, T_TABLE_2 B WHERE A.SSID = B.SSID AND B.NUMBER = '123456';`

2)

delete from T_TABLE_3 where ssid='139729252';
delete from T_TABLE_4 where ssid='139729252';

1)的结果是SSID,例如:' 139729252' ,我怎样才能将1)的结果用于2),每次都不需要复制粘贴?感谢。

2 个答案:

答案 0 :(得分:0)

如果您希望使用select语句检索多个记录,请使用IN运算符。否则你可以使用= operator。

例如:

delete from T_TABLE_3 where ssid=(SELECT A.SSID FROM T_TABLE_1 A, T_TABLE_2 B WHERE A.SSID = B.SSID AND B.NUMBER = '123456');

delete from T_TABLE_3 where ssid IN (SELECT A.SSID FROM T_TABLE_1 A, T_TABLE_2 B WHERE A.SSID = B.SSID AND B.NUMBER = '123456');

答案 1 :(得分:0)

从T_TABLE_3删除ssid in(选择a.ssid t_table_1 a,t_table_2 b,其中a.ssid = b.ssid和b.number =' 123456');