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

数据库查询语句书写问题求助

  •  
  •   UnPace · Jun 23, 2016 · 2222 views
    This topic created in 3695 days ago, the information mentioned may be changed or developed.

    这是 discuz 的一个插件,在后台,插件是这样设置来确定分类的,一个分类 ID 对应一个分类名称。

    但是数据库中只记录的分类 ID ,没有分类名称,在写数据库查询语句时,怎么根据 ID 获得分类名称?

    http://ww2.sinaimg.cn/large/b66f7a21gw1f55435t784j204707xt8n.jpg

    http://ww4.sinaimg.cn/large/b66f7a21gw1f5543dcb00j20n90cudh3.jpg

    jhdxr
        1
    jhdxr  
       Jun 23, 2016
    SQL 解决不了(或者说代价过高,毕竟 SQL 也是能写代码的。。。),你需要查出来以后自己去替换,上面的设置是作为普通的文本保存的,你需要自己解析
    tjxjj
        2
    tjxjj  
       Jun 23, 2016
    decode 啊。适用于类别固定的情况。
    UnPace
        3
    UnPace  
    OP
       Jun 23, 2016
    @jhdxr 谢谢你,提供了个很好的思路。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3096 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 13:06 · PVG 21:06 · LAX 06:06 · JFK 09:06
    ♥ Do have faith in what you're doing.