Re: [SQL ] 如何select 出1到x之間的空號呢?
※ 引述《iFEELing (ing)》之銘言:
: 我比較好奇 既然原始資料已經被幹掉了,你怎麼知道哪個號碼實際上被幹掉的原因是啥
那是使用者的問題,跟程式無關。也許會要求整批填上"測試刪除...etc"之類吧
: : 一個暫時的想法,如果這件事只需要做一次的話,或許可以這樣
: cretea table t2(
: (
: ID int
: );
: 在 T2 中 insert 數列 , ID=1 , ID=2,ID=3......ID = x;
: 然後
: select id from T2 where ID not in (select id from T1)
:
感謝回答,
我最後的想法:。作一個 temp table 如上的。
create table temp(id int);
insert into temp(id) values(1,2,3,4,.......x);
create table t2 (id int, why text);
insert into t2 (id)
select id from temp where id not in (select id from t1);
另外maplenote大大直接回至本人信箱,亦十分感謝。
信裡提到,"程式還不是都要改,直接加上isdelete....."
我順便在這回應一下。這只是個總號管理的table。
實際上不同的單據,有不同的資料管理畫面、報表。約有30個左右。
而作廢(刪除),只有一個地方。
修改:作廢。並加上作廢清單與理由update。共計:修1加1
加欄位的方式,恐怕要改60以上的地方。
以上。謝謝各位大大的回答。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.161.69.99
討論串 (同標題文章)