› MySQL 5.5 Community Server
› MySQL 5.6 Community Server
› Percona Configuration Wizard
› XtraBackup 搭建主从复制
Great Sites on MySQL
› Percona
› MySQL Performance Blog
› Severalnines
推荐管理工具
› Sequel Pro
› phpMyAdmin
推荐书目
› MySQL Cookbook
MySQL 相关项目
› MariaDB
› Drizzle
参考文档
› http://mysql-python.sourceforge.net/MySQLdb.html
Routeros
V2EX  ›  MySQL

求一行 sql

  •  
  •   Routeros · Sep 4, 2021 · 2819 views
    This topic created in 1904 days ago, the information mentioned may be changed or developed.

    如果可以的话我提一个要求就是希望这个 sql 能在 mysql 和 oracle 上使用。 目前有如下两个表: tableA 字段众多,其中一个是 codeA 。 tableB 就两个字段,一个是 id:1 、2 、3 、4 、5.... 另一个是 codeB:6 位数字。 tableA 、tableB 无任何关联....

    要求:
    随机选择 codeB 中的一个 给表格 A 的 codeA 字段。
    
    比如表格 A 有一百行,就随机一百次 codeB 列给 codeA 即可。。
    
    ReferenceE
    ReferenceE
    Sep 4, 2021 via Android❤️2
    1
    产品请去找自己公司的程序员(🐶
    fiypig
    fiypig
    Sep 4, 2021 via iPhone
    2
    随机插入 a 是吧,不难
    liuguangxuan
    liuguangxuan
    Sep 4, 2021 via Android
    3
    啊,这…
    auh
    auh
    Sep 4, 2021
    4
    挺好,能不能一行 sql 帮我实现一下人生巅峰
    xmtpw
    xmtpw
    Sep 5, 2021 via iPhone
    5
    给你,一行 sql
    KKLeon
    KKLeon
    Sep 5, 2021 via Android
    6
    sqlsqlsqlsqlsqlsqlsql🐶
    Routeros
    Routeros
    OP
    Sep 5, 2021
    7
    纯讨论,可以不说,没必要瞎指点。抖机灵更没 6
    shakaraka
    shakaraka
    Sep 5, 2021
    8
    sql := "一行 sql"
    Routeros
    Routeros
    OP
    Sep 5, 2021
    9
    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;
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   898 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 22:44 · PVG 06:44 · LAX 14:44 · JFK 17:44
    ♥ Do have faith in what you're doing.