Reputation: 49
I have this query:
select carrier_id, order_id,aircraft_id,quantity
from orderline
innerjoin purchaseorder on orderline.order_id = purchaseorder.carrier_id;
im getting the ambiguous error, I know I have to use aliases but it doesnt work ie:
select carrier_id as cID, order_id as OID,aircraft_id,quantity
from orderline
innerjoin purchaseorder on orderline.order_id as OID = purchaseorder.carrier_id as cID
it says invalid relational operator ?
thanks for your help guys :)
Upvotes: 1
Views: 255
Reputation: 70638
The problem is that after you did the JOIN
, you are selecting some columns. Some of those columns probably have the same name on both tables, and you need to specify wich one is it:
select P.carrier_id, O.order_id, O.aircraft_id, P.quantity --use the right prefix
from orderline AS O
inner join purchaseorder AS P
on O.order_id = P.carrier_id;
Upvotes: 1
Reputation: 3226
You need a space in your INNER JOIN
. Not INNERJOIN
.
select carrier_id, order_id,aircraft_id,quantity
from orderline
inner join purchaseorder on orderline.order_id = purchaseorder.carrier_id;
Also, as the other answerer said, your columns may be ambiguously defined (same column name in each table), so you need to prefix the columns with your table name i.e.( select orderline.orderid
)
Upvotes: 2