• 错误代码: 1248 Every derived table must have its own alias


    1、错误描述

    1 queries executed, 0 success, 1 errors, 0 warnings
    
    查询:SELECT stu_id, (SELECT stu_name FROM t_student_info t WHERE t.stu_id = t.stu_id) stu_name FROM (SELECT SUM( CASE course WHEN '敮..
    
    错误代码: 1248
    Every derived table must have its own alias
    
    执行耗时   : 0 sec
    传送时间   : 0 sec
    总耗时      : 0 sec
    

    2、错误原因

    SELECT 
      stu_id,
      (SELECT 
        stu_name 
      FROM
        t_student_info t 
      WHERE t.stu_id = t.stu_id) stu_name 
    FROM
      (SELECT 
        SUM(
          CASE
            course 
            WHEN '数学' 
            THEN Score 
            ELSE 0 
          END
        ) 数学,
        SUM(
          CASE
            course 
            WHEN '语文' 
            THEN score 
            ELSE 0 
          END
        ) 语文,
        SUM(
          CASE
            course 
            WHEN '英语' 
            THEN score 
            ELSE 0 
          END
        ) 英语,
        stu_id 
      FROM
        t_score_info 
      GROUP BY stu_id)

    3、解决办法

    SELECT
    	*
    FROM
    	(
    		SELECT
    			stu_no
    		FROM
    			t_student_info
    		UNION
    			SELECT
    				stu_no
    			FROM
    				t_student_info
    	) student;
         在后面给联合查询取个别名student
      

  • 相关阅读:
    Linux let 命令
    perl hash array 嵌套 push
    Perl CGI编程
    Perl关联数组用法集锦
    关于反射和动态代理
    SpringBoot与web开发
    Springboot与日志
    Spring Boot
    SpringBoot的自动配置原理
    Spring MVC执行流程
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13314512.html
Copyright © 2020-2023  润新知