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

小白 sql 刚学,有个 sql 语句脑子转不过来,大牛进来看看。

  •  
  •   phantomer · Aug 26, 2015 · 3885 views
    This topic created in 4089 days ago, the information mentioned may be changed or developed.
    select*from (select user ())a

    中的 a 是啥意义?

    select*from (select table_name from information_schema.tables where table_schema=database () limit 0,1 )
    像这样 mysql 里执行是报错的。

    select*from (select table_name from information_schema.tables where table_schema=database () limit 0,1 )a 就可以成功执行,为什么呢?
    10 replies  •  2016-03-17 10:40:34 +08:00
    realpg
    realpg
    Aug 26, 2015
    1
    别名。。。
    nandaye
    nandaye
    Aug 26, 2015
    2
    Error Code: 1248. Every derived table must have its own alias
    必须要有别名 这个是 mysql 的规定 oracle 如果没有别名是不会报错的
    helone
    helone
    Aug 26, 2015
    3
    a = AS a
    idblife
    idblife
    Aug 26, 2015
    4
    别名
    不过你为啥这么写,很奇怪
    Smilecc
    Smilecc
    Aug 26, 2015
    5
    实际上是 select*from (select user ()) as a
    from 后面紧跟的是 table
    而使用 select 语句选出来的是一组元组,不能直接查询
    所以使用 as 给这个元组重命名为叫 a 的一张表,这样前面的 select 就成立了
    ohmycodeape
    ohmycodeape
    Aug 26, 2015
    6
    别名 连接查询或者子查询时会用到
    jhdxr
    jhdxr
    Aug 26, 2015
    7
    目测是在玩注入_(:з」∠)_
    RIcter
    RIcter
    Aug 26, 2015 via iPhone
    8
    @jhdxr 樓主就是大黑闊
    Ouyangan
    Ouyangan
    Aug 26, 2015
    9
    as nickname
    noahliaszn
    noahliaszn
    Mar 17, 2016
    10
    木有 alias
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1317 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 18:56 · PVG 02:56 · LAX 10:56 · JFK 13:56
    ♥ Do have faith in what you're doing.