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