EE v2 to v5 upgrade SQL error when selecting channel for editing an entry

50 Views Asked by At

The upgrade from v2 to v5 proceeded without error, as did upgrading several plugins, however when in the control panel and I select 'Edit' > and filter by a channel I get the following error:

SQLSTATE[23000]: Integrity constraint violation: 1052 Column ‘channel_id’ in where clause is ambiguous:

Code:

SELECT DISTINCT t.author_id, m.screen_name 
FROM (exp_channel_titles t) 
LEFT JOIN exp_members m ON m.member_id = t.author_id 
WHERE channel_id = 83 
ORDER BY screen_name asc

Any help identifying the cause of this error and providing a fix would be very much appreciated

Note: I understand what the error means and how to fix it, what I need to know is what is going wrong and how to fix it in relation to the framework that it's used in Expression Engine.

1

There are 1 best solutions below

2
Lajos Arpad On

You have channel_id as a column both in your exp_channel_titles and your exp_member table, and the query handler just cannot guess which one it needs to use.

The solution is to either use t.channel_id or exp_members.channel_id instead of just channel_id, so your query will be more specific. You will need to determine which one is the correct one.