› 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
uti6770werty
V2EX  ›  MySQL

请教两条查询语句,值集合在和不在表内的结果?

  •  
  •   uti6770werty · Dec 2, 2020 · 2115 views
    This topic created in 2126 days ago, the information mentioned may be changed or developed.
    程序生成了一个数据集合,不想逐条去查询是否存在,程序拼装了一个数据集合,不知道 MySQL 是否允许这样的单句查询?
    ('7075651','888','112233','00998877')

    查询 1 、根据以上数据集合,输出不在 alldata 表内`dataid`字段的数据?
    查询 2 、根据以上数据集合,输出在 alldata 表内`dataid`字段的数据?
    1 replies  •  2020-12-02 18:31:52 +08:00
    Edsie
        1
    Edsie  
       Dec 2, 2020
    ```
    select t.*, case a.id when null then 'y' else 'n' end
    from (SELECT
    SUBSTRING_INDEX(SUBSTRING_INDEX('7654,7698,7782,7788',',',help_topic_id+1),',',-1) AS num
    FROM
    mysql.help_topic
    WHERE
    help_topic_id < LENGTH('7654,7698,7782,7788')-LENGTH(REPLACE('7654,7698,7782,7788',',',''))+1
    ) t
    left join alldata a on a.id = t.num

    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4378 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 09:51 · PVG 17:51 · LAX 02:51 · JFK 05:51
    ♥ Do have faith in what you're doing.