V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
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
hellohacker
V2EX  ›  MySQL

mysql 根据传入的数据排序的问题

  •  
  •   hellohacker · Aug 5, 2014 · 4233 views
    This topic created in 4286 days ago, the information mentioned may be changed or developed.
    如下:
    select count(*) as num from a where id in (11,12,9,4,15) group by id;

    这样输出数据后,不是按照 id的数据顺序 11,12,9,4,15 输出的

    求解决方案 3Q!
    3 replies    2014-08-05 11:54:25 +08:00
    yangqi
        1
    yangqi  
       Aug 5, 2014   ❤️ 3
    ORDER BY FIELD(ID,11,12,9,4,15)
    hcy
        2
    hcy  
       Aug 5, 2014   ❤️ 1
    order by field(id ,11,12,9,4,15)
    试下这个。
    hellohacker
        3
    hellohacker  
    OP
       Aug 5, 2014
    @yangqi
    @hcy

    3Q 2 位 问题已解决
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2670 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 12:00 · PVG 20:00 · LAX 05:00 · JFK 08:00
    ♥ Do have faith in what you're doing.