Rob Brandt
Rob Brandt

Reputation: 292

MySQL error "An alias was previously found" when an alias isn't in the query

I have a very odd error while trying to perform an update on a database. This is on an Ubuntu 16.04 server using MySQL 5.7.19-0ubuntu0.16.04.1. The query is:

UPDATE athlet_teamseason SET offkeyreturners = 'test' WHERE athlet_teamseason.id = 29701;

The MySQL error is:

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 'offkeyreturners = 'test' WHERE athlet_teamseason.id = 29701' at line 1

I am doing this in phpMyAdmin, and it gives a bit more information:

2 errors were found during analysis.

An alias was previously found. (near " " at position 50) An alias was previously found. (near "'test'" at position 51)

If I try this update directly in the phpMyAdmin user interface (search for record, edit field value, submit form) it works, and the query shown is:

UPDATE athlet_teamseason SET offkeyreturners = 'test' WHERE athlet_teamseason.id = 29701;

which appears to be identical. HOWEVER, if I do a string comparison between the two I get:

Diff showing query differences

So while they appear to be the same, there is a difference somewhere.

The queries were created from a table in a database, using concatenation and referencing cells in a source table. For example:

="UPDATE athlet_teamseason SET offkeyreturners = '"&data!I2&"' WHERE athlet_teamseason.id = "&data!A2&";"

I have thousands of these and they all produce the same error. I've done this dozens of times in older servers, might be an issue with MySQL 5.7?

Upvotes: 1

Views: 1778

Answers (1)

Rob Brandt
Rob Brandt

Reputation: 292

Thanks to Uueerdo, I eliminated non-printing characters in my query.

Upvotes: 0

Related Questions