
如果可以的话我提一个要求就是希望这个 sql 能在 mysql 和 oracle 上使用。 目前有如下两个表: tableA 字段众多,其中一个是 codeA 。 tableB 就两个字段,一个是 id:1 、2 、3 、4 、5.... 另一个是 codeB:6 位数字。 tableA 、tableB 无任何关联....
要求: 随机选择 codeB 中的一个 给表格 A 的 codeA 字段。 比如表格 A 有一百行,就随机一百次 codeB 列给 codeA 即可。。 1 ReferenceE 2021-09-04 21:24:14 +08:00 via Android 产品请去找自己公司的程序员( |
2 fiypig 2021-09-04 22:32:06 +08:00 via iPhone 随机插入 a 是吧,不难 |
3 liuguangxuan 2021-09-04 22:38:59 +08:00 via Android 啊,这… |
4 auh 2021-09-04 22:42:17 +08:00 挺好,能不能一行 sql 帮我实现一下人生巅峰 |
5 xmtpw 2021-09-05 00:05:14 +08:00 via iPhone 给你,一行 sql |
6 KKLeon 2021-09-05 00:13:53 +08:00 via Android sqlsqlsqlsqlsqlsqlsql |
7 Routeros OP 纯讨论,可以不说,没必要瞎指点。抖机灵更没 6 |
8 shakaraka PRO sql := "一行 sql" |
9 Routeros OP create or replace procedure proc_random_records_test is v_cur_count int := 0; v_cur_random int; v_cur_seq_row rowid; begin for item in (select rowid from yangsonglin1) loop v_cur_seq_row := item.rowid; select code2 into v_cur_random from (select code2 from yangsonglin2 order by dbms_random.value) where rownum <= 1; update yangsonglin1 set code1 = v_cur_random where rowid = v_cur_seq_row; if v_cur_count = 0 then exit; end if; dbms_output.put_line('success !'); end loop; --commit; end; begin proc_random_records_test; end; select * from yangsonglin1; |