MySQL duplicates with CONCAT error 1548 - Cannot load from mysql.proc. The table is probably corrupted

隐身守侯 提交于 2019-12-24 23:23:51

问题


i have this query witch concatenates firstname with last name and then find the duplicates:

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

i think the sql syntax is correct but i get the error: 1548 - Cannot load from mysql.proc. The table is probably corrupted

is there any problem with the 5.1.59 mysql version?


回答1:


Do that

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

instead of

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

Update

Try that:

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



回答2:


Change

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

to

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

Note the change to the CONCAT statement and the as addition for using column aliases

as you are using a single table you could remove the import. from the column list ... alternatively you could use a table alias

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

as an example.

See the MySQL docs here on using the AS alias




回答3:


Examines all tables in all databases for incompatibilities with the current version of MySQL Server:

mysql_upgrade -uroot -p

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



来源:https://stackoverflow.com/questions/9566085/mysql-duplicates-with-concat-error-1548-cannot-load-from-mysql-proc-the-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!