【问题标题】:MySQL duplicates with CONCAT error 1548 - Cannot load from mysql.proc. The table is probably corruptedMySQL 与 CONCAT 错误 1548 重复 - 无法从 mysql.proc 加载。该表可能已损坏
【发布时间】:2012-03-05 11:46:59
【问题描述】:

我有这个查询,女巫将名字与姓氏连接起来,然后找到重复项:

SELECT import.*, import.CONCAT(nume,' ',prenume) full2 
FROM import 
INNER JOIN (SELECT CONCAT(nume,' ',prenume) full,COUNT(*) 
            FROM import 
            WHERE users_id=1 
            GROUP BY full 
            HAVING COUNT(*)>1) as t2 ON import.full2 = t2.full 
WHERE users_id=1

我认为 sql 语法是正确的,但我收到错误:1548 - 无法从 mysql.proc 加载。该表可能已损坏

mysql 5.1.59版本有问题吗?

【问题讨论】:

    标签: mysql duplicates concat


    【解决方案1】:

    这样做

    CONCAT(import.nume,' ',import.prenume) full2 
    

    而不是

    import.CONCAT(nume,' ',prenume) full2 
    

    更新

    试试看:

    SELECT t1.*, CONCAT(t1.nume,' ',t1.prenume) full2 
    FROM import t1
    INNER JOIN (SELECT CONCAT(i2.nume,' ',i2.prenume) `full`, COUNT(*) 
            FROM import i2
            WHERE i2.users_id=1 
            GROUP BY `full`
            HAVING COUNT(*)>1) as t2 ON full2 = t2.`full` 
    WHERE users_id=1
    

    【讨论】:

    • 我在没有导入的情况下在“on 子句”中得到未知列“import.full2”。
    • 将 on 子句中的 import.full2 更改为 full2
    • 我做到了,但仍然未知列
    • “on 子句”中的未知列“t1.full2”
    • 啊。我的错。您是否尝试将t1. 放在full 之前:ON full2 = t2.full。如果这不起作用。那我就不知道了。
    【解决方案2】:

    改变

    SELECT import.*, import.CONCAT(nume,' ',prenume) full2 
    

    SELECT import.*, CONCAT(import.nume,' ',import.prenume) as full2 
    

    注意对CONCAT 语句的更改以及使用列别名的as 添加

    当您使用单个表时,您可以从列列表中删除 import. ... 或者您可以使用表别名

    SELECT i.*, CONCAT(i.nume,' ',i.prenume) as full2 
    FROM import i
    WHERE i.user_id = 1
    

    举个例子。

    See the MySQL docs here on using the AS alias

    【讨论】:

      【解决方案3】:

      检查所有数据库中的所有表是否与当前版本的 MySQL 服务器不兼容:

      mysql_upgrade -uroot -p
      

      http://dev.mysql.com/doc/refman/5.0/en/mysql-upgrade.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-01-26
        • 2017-10-21
        • 2019-10-31
        • 2020-07-22
        • 1970-01-01
        • 1970-01-01
        • 2021-12-07
        相关资源
        最近更新 更多