MySQL: The Multi-part Identifier "u.id" Could Not Be Bound
Posted December 18, 2008 at 9:19 AM
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:
Launch code in new window » Download code as text file »
- UPDATE
- [user]
- SET
- is_active = 1
- WHERE
- 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.
Download Code Snippet ZIP File
Post Comment | Ask Ben | Other Searches | Print Page
Newer Post
Kinky Solutions Shop - Holiday Season Beta Launch
Older Post
ColdFusion ARGUMENTS Keys Always Exist, Even When Not Required
Reader Comments
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.
@Jon,
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
@Dugeen,
Awesome. Glad this could help.



