zoukankan      html  css  js  c++  java
  • mysql

    问题描述:

    case后的字段,加表名时,会报错,如下:

    1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.type

    FROM

    agency_vms' at line 7, Time: 0.024000s

    如下代码有问题:

    SELECT
        agency_name,
        agency_vms.type as adbw,
        case agency_vms.type
            when 'PCS' then '审方机构'
            when 'VS' then '复诊机构'
        end as agency_vms.type
        
    FROM
    agency_vms

    解决方案:

    case后的字段用表名.字段名,end后的用重命名字段

    SELECT
        agency_name,
        agency_vms.type as adbw,
        case agency_vms.type
            when 'PCS' then '审方机构'
            when 'VS' then '复诊机构'
        end as adbw     -- 将end后的改为重命名字段
        
    FROM
    agency_vms
  • 相关阅读:
    2.19
    2.16sqlite
    2.14Android6
    2.12Android5
    2.11Android4
    2.09Android3
    2.08Android2
    2.06Android学习
    dpdk bond
    ContainerCreating
  • 原文地址:https://www.cnblogs.com/xiaochongc/p/13841465.html
Copyright © 2011-2022 走看看