推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
shimingzhoudf
V2EX  ›  Python

mysql 查询

  •  
  •   shimingzhoudf · Sep 4, 2020 · 3290 views
    This topic created in 2212 days ago, the information mentioned may be changed or developed.

    A 表有 1,2,3,4 个字段

    我现在查询结果需要是这样

    表名 中文名 1 2 3 4 数据 x x x x x ... ... .. .. .. ..

    其实中文名就是 4 字段的值

    我看别人这样写过: select 4 中文名, * where 表名;

    但我自己用老报语法错误

    10 replies  •  2020-09-07 10:38:46 +08:00
    shimingzhoudf
        1
    shimingzhoudf  
    OP
       Sep 4, 2020
    语法是这样 select 4 中文名, * from 表名 where 条件;
    qiayue
        2
    qiayue  
       Sep 4, 2020
    指定了字段名之后,不能用 * 了吧
    specita
        3
    specita  
       Sep 4, 2020
    描述得让人看不懂,建议直接贴 sql 和异常
    shimingzhoudf
        4
    shimingzhoudf  
    OP
       Sep 4, 2020
    @specita 这个展示出来没换行
    goodboy95
        5
    goodboy95  
       Sep 4, 2020
    命令行的话,你直接 select *,上面应该自带字段名
    程序里面用的话,你 select 出来之后,肯定要自己把字段名拼上去
    twinsdestiny
        6
    twinsdestiny  
       Sep 4, 2020
    select 4 中文名,t.* from 表名 t
    加个别名应该可以
    foolgry
        7
    foolgry  
       Sep 5, 2020
    *放前面试试
    xsonglive
        8
    xsonglive  
       Sep 5, 2020
    用别名可以的.
    shimingzhoudf
        9
    shimingzhoudf  
    OP
       Sep 7, 2020
    @twinsdestiny 可以的,感谢
    shimingzhoudf
        10
    shimingzhoudf  
    OP
       Sep 7, 2020
    @xsonglive 加个别名能达到我期望要求
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2522 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 09:19 · PVG 17:19 · LAX 02:19 · JFK 05:19
    ♥ Do have faith in what you're doing.