V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
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 · 2014-08-05 11:28:50 +08:00 · 3268 次点击
    这是一个创建于 3552 天前的主题,其中的信息可能已经有所发展或是发生改变。
    如下:
    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 条回复    2014-08-05 11:54:25 +08:00
    yangqi
        1
    yangqi  
       2014-08-05 11:34:18 +08:00   ❤️ 3
    ORDER BY FIELD(ID,11,12,9,4,15)
    hcy
        2
    hcy  
       2014-08-05 11:41:16 +08:00   ❤️ 1
    order by field(id ,11,12,9,4,15)
    试下这个。
    hellohacker
        3
    hellohacker  
    OP
       2014-08-05 11:54:25 +08:00
    @yangqi
    @hcy

    3Q 2 位 问题已解决
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2834 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 11:46 · PVG 19:46 · LAX 04:46 · JFK 07:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.