MySQL Error - "Unknown column in where clause"


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?
Who is Participating?
HackneyCabConnect With a Mentor Commented:
According to your query, the table name is video, not channel.
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!
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:
SpiderstaveAuthor Commented:
Great resource, thank you!
Oh, just remember to check which version of MySQL you're using and change the /5.0/ in the URL to suit your version.
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.