MySQL Error - "Unknown column in where clause"

Hello,

I'm having a strange issue. When I use this query:

SELECT count(VID) AS total, UID FROM video WHERE channel LIKE '%|22|%' GROUP BY UID ORDER BY total DESC LIMIT 5

Everything works fine. But when I duplicate the "channel" table and call the new table "channel_cl", then run the exact same query, but with the new table name:

SELECT count(VID) AS total, UID FROM video WHERE channel_cl LIKE '%|22|%' GROUP BY UID ORDER BY total DESC LIMIT 5

I receive this error:

Unknown column 'channel_cl' in 'where clause'

I don't understand why the query is working on the original table, but not after I duplicate the table. Does anyone have any ideas?
SpiderstaveAsked:
Who is Participating?
 
HackneyCabConnect With a Mentor Commented:
According to your query, the table name is video, not channel.
0
 
SpiderstaveAuthor Commented:
Whoops! I got confused because there is a table called channels, and didn't realize it was referencing a column called channels, not the table. That fixed it. Thanks!
0
 
HackneyCabCommented:
No problem. You should have the MySQL manual handy for such occassions. I can never remember the syntax of all those different types of statements either, but the manual lays it out nicely:

http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-data-manipulation.html
0
 
SpiderstaveAuthor Commented:
Great resource, thank you!
0
 
HackneyCabCommented:
Oh, just remember to check which version of MySQL you're using and change the /5.0/ in the URL to suit your version.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.