Home > database >  How do i fix Ambiguous column name 'Venue_code'. error
How do i fix Ambiguous column name 'Venue_code'. error

Time:04-12

this is my sql code where I'm creating a join. Now when I run it, it tells me the following: Ambiguous column name 'Venue_code'. How do i fix this?

 SELECT Venue_name,Customer_name,Checkin_date,nights
 from Venues,Customers,Accomodation_booking`enter code here`
  where Venues.Venue_code = Accomodation_booking.Venue_code
  AND Customers.Customer_ID = Accomodation_booking.Customer_ID
 AND Venue_code  Code = 'V0001';

CodePudding user response:

The last line looks suspicious. If you meant Venue_code = 'V0001' then remove Code and change Venue_code to either Venues.Venue_code or Accomodation_booking.Venue_code.

You probably had difficulties because you use SO for the first time. The code does not look clean. Remove the enter code here part too (end of second line).

CodePudding user response:

If you join two (or more) tables and one or more column names are used in more than one table you need to prefix it but you didn't do it in your last line. It seems there is more than one error

AND Venue_code  Code = 'V0001';

did you mean?

AND Venues.Venue_code = 'V0001';
  •  Tags:  
  • sql
  • Related