程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> in-簡單SQL語句中如何帶參與執行

in-簡單SQL語句中如何帶參與執行

編輯:編程解疑
簡單SQL語句中如何帶參與執行

先做原表備份
CREATE TABLE A_1 AS SELECT * FROM A WHERE aa IN ('eimdmc','30mdnci','cienc03','39n33ndc','c035mcie','cnencc0394','cnednc003','ciiencec004','cinendnc00','2098472bnc','cnenndcj93','398473c3d','cjbebcencc','397c73becu','393knencne','398883jjdnc','83737jecnd','398838cjebc','e993nndn3','dii3nndn','300993983d');
CREATE TABLE B_1 AS SELECT * FROM B WHERE aa IN ('eimdmc','30mdnci','cienc03','39n33ndc','c035mcie','cnencc0394','cnednc003','ciiencec004','cinendnc00','2098472bnc','cnenndcj93','398473c3d','cjbebcencc','397c73becu','393knencne','398883jjdnc','83737jecnd','398838cjebc','e993nndn3','dii3nndn','300993983d');
CREATE TABLE C_1 AS SELECT * FROM C WHERE aa IN ('eimdmc','30mdnci','cienc03','39n33ndc','c035mcie','cnencc0394','cnednc003','ciiencec004','cinendnc00','2098472bnc','cnenndcj93','398473c3d','cjbebcencc','397c73becu','393knencne','398883jjdnc','83737jecnd','398838cjebc','e993nndn3','dii3nndn','300993983d');
CREATE TABLE D_1 AS SELECT * FROM D WHERE aa IN ('eimdmc','30mdnci','cienc03','39n33ndc','c035mcie','cnencc0394','cnednc003','ciiencec004','cinendnc00','2098472bnc','cnenndcj93','398473c3d','cjbebcencc','397c73becu','393knencne','398883jjdnc','83737jecnd','398838cjebc','e993nndn3','dii3nndn','300993983d');
CREATE TABLE E_1 AS SELECT * FROM E WHERE aa IN ('eimdmc','30mdnci','cienc03','39n33ndc','c035mcie','cnencc0394','cnednc003','ciiencec004','cinendnc00','2098472bnc','cnenndcj93','398473c3d','cjbebcencc','397c73becu','393knencne','398883jjdnc','83737jecnd','398838cjebc','e993nndn3','dii3nndn','300993983d');
........
在做原表數據刪除
delete FROM A where aa in ('eimdmc','30mdnci','cienc03','39n33ndc','c035mcie','cnencc0394','cnednc003','ciiencec004','cinendnc00','2098472bnc','cnenndcj93','398473c3d','cjbebcencc','397c73becu','393knencne','398883jjdnc','83737jecnd','398838cjebc','e993nndn3','dii3nndn','300993983d');
delete FROM B where aa in ('eimdmc','30mdnci','cienc03','39n33ndc','c035mcie','cnencc0394','cnednc003','ciiencec004','cinendnc00','2098472bnc','cnenndcj93','398473c3d','cjbebcencc','397c73becu','393knencne','398883jjdnc','83737jecnd','398838cjebc','e993nndn3','dii3nndn','300993983d');
delete FROM C where aa in ('eimdmc','30mdnci','cienc03','39n33ndc','c035mcie','cnencc0394','cnednc003','ciiencec004','cinendnc00','2098472bnc','cnenndcj93','398473c3d','cjbebcencc','397c73becu','393knencne','398883jjdnc','83737jecnd','398838cjebc','e993nndn3','dii3nndn','300993983d');
delete FROM D where aa in ('eimdmc','30mdnci','cienc03','39n33ndc','c035mcie','cnencc0394','cnednc003','ciiencec004','cinendnc00','2098472bnc','cnenndcj93','398473c3d','cjbebcencc','397c73becu','393knencne','398883jjdnc','83737jecnd','398838cjebc','e993nndn3','dii3nndn','300993983d');
delete FROM E where aa in ('eimdmc','30mdnci','cienc03','39n33ndc','c035mcie','cnencc0394','cnednc003','ciiencec004','cinendnc00','2098472bnc','cnenndcj93','398473c3d','cjbebcencc','397c73becu','393knencne','398883jjdnc','83737jecnd','398838cjebc','e993nndn3','dii3nndn','300993983d');
........
這兩個組的語句中 in 後面都有很長的參數,而且都是完全一樣的。
怎麼能夠用參數替代這個in之後的語句。
希望使用簡單sql

最佳回答:


是的,講這些數據放到一張表裡,然後 select * from xxx where 字段 in (select 字段 from tablexxxx)

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved