› 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 · 2669 views
    This topic created in 1854 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
        1
    ReferenceE  
       Sep 4, 2021 via Android   ❤️ 2
    产品请去找自己公司的程序员(🐶
    fiypig
        2
    fiypig  
       Sep 4, 2021 via iPhone
    随机插入 a 是吧,不难
    liuguangxuan
        3
    liuguangxuan  
       Sep 4, 2021 via Android
    啊,这…
    auh
        4
    auh  
       Sep 4, 2021
    挺好,能不能一行 sql 帮我实现一下人生巅峰
    xmtpw
        5
    xmtpw  
       Sep 5, 2021 via iPhone
    给你,一行 sql
    KKLeon
        6
    KKLeon  
       Sep 5, 2021 via Android
    sqlsqlsqlsqlsqlsqlsql🐶
    Routeros
        7
    Routeros  
    OP
       Sep 5, 2021
    纯讨论,可以不说,没必要瞎指点。抖机灵更没 6
    shakaraka
        8
    shakaraka  
       Sep 5, 2021
    sql := "一行 sql"
    Routeros
        9
    Routeros  
    OP
       Sep 5, 2021
    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   ·   2244 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 15:59 · PVG 23:59 · LAX 08:59 · JFK 11:59
    ♥ Do have faith in what you're doing.