I had never seen this error before, so I thought I would just take a second to post it in case anyone tries to Google it. Luckily, my query was extremely small and so the error was obvious from a quick review of the SQL; but, in a large query this might not be readily apparent. Here's the kind of query I was running in MySQL:
- is_active = 1
- u.id = 4
Can you see what the problem is? My WHERE clause uses an aliased table name, but my UPDATE clause did not alias the table. I am so used to using aliased tables that when I saw the error, it didn't even occur to me that the aliasing itself was causing the issue. Once I removed the alias "u.", the query worked fine.
Again, a really minor note, but I thought it might help someone.
Looking For A New Job?
- Operations Analyst II at Sears Holdings
- Senior Web Applications Developer at QM Quality Matters
- ColdFusion Developer Needed - Jr. and Sr. Positions at InterCoastal Net Designs
- WEB DESIGNER (Information Officer 3) at Southwest Minnesota State University
I've done this quite a few times. Its why I've trained myself to always use the alias, even when working with a single table.
Agreed; I try to use the alias all the time. I just like it for some reason - I think it adds readability to the query (although that may just be a purely emotional response).
Yes that did help. Thanks
Awesome. Glad this could help.
Ah this helped me a lot, mine query was big one and I did aliased the table but after reading this when I checked back the query, there was a typo in alias. :-) So lots of time saved.
Thank you so much for this!
Glad this helped :)
I have meet the same question,but I don't think the origin error is the alias but the alias the way use it ,I recommened the way you use it like this:
SET u.is_active = 1
from users as u
WHERE u.id = 4
Simple! It helps a lot !!
You save my day again Ben.