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

对于 in 查询,如何限制每个组合数据的条数呢

  •  
  •   FrankAdler · Dec 9, 2022 · 2370 views
    This topic created in 1440 days ago, the information mentioned may be changed or developed.

    比如 uid in (1001,1002) and type in (1,2)

    uid 可能有很多,比如 60 个,type 每种只取最后一个,最终数据最多 60*2=120 条

    相当于 uid = 1001 and type in(1,2) order by id limit 1 这样查询 60 次,现在想一条 sql 解决

    4 replies  •  2022-12-10 00:47:02 +08:00
    chinni
    chinni
    Dec 9, 2022
    1
    row_number ,partition by , order by
    FrankAdler
    FrankAdler
    OP
    Dec 9, 2022
    2
    @chinni 感谢,我研究下看看
    liaohongxing
    liaohongxing
    Dec 10, 2022
    3
    搜一下窗口函数
    FrankAdler
    FrankAdler
    OP
    Dec 10, 2022
    4
    @liaohongxing 好的,谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4406 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 08:04 · PVG 16:04 · LAX 00:04 · JFK 03:04
    ♥ Do have faith in what you're doing.