I have the following SQL Query :
SELECT call_type FROM INCOMING_CALLS, LIVE_CALLS
WHERE LIVE_CALLS.status='INCALL' and INCOMING_CALLS.callerid = LIVE_CALLS.callerid
AND pbl_id in ('111','190','121','111','-','111','121','303','6730','-');
Both the tables, LIVE_CALLS and INCOMING_CALLS have the column pbl_id. Which obviously results into the following error :
ERROR 1052 (23000): Column 'pbl_id' in where clause is ambiguous
I understand that it’s very simple to solve this problem by changing
pbl_id in (
to
INCOMING_CALLS.pbl_id in (
and
INCOMING_CALLS.pbl_id in (
But I can not do that as the below part is dynamically dynamically build and I do not have control over it.
AND pbl_id in ('111','190','121','111','-','111','121','303','6730','-');
I need to match the pbl_id of both tables. Any hints how can I achieve that?
You could use a sub-query:
See it here.