I have three tables 1. Ordertable 2. Bill 3. Customers
In Ordertable I have following columns
(*) represents Primary key here
| Customer ID*c| Customer Name | Address | Contact Number | Email|
In Order table I have following columns
| Order ID* | Order Status | Delivery Date | Manager ID | Customer ID| Salesmanager ID| Where Order_status can Containt ‘pending’ for pending order And ‘completed ’ for for completed order
In bill table I have these columns
| Bill ID*| Order ID | Date | Amount |
Now I want to create Query that display completed Order data with inner join on these three as these rules
- Order_ID as OID from order table
- Order_Status as Status from order table
- Delivery_Date as Date from order table
- Customer_name as Name from customer table
- Amount as Bill Amount from Bill table What I tries is this Query
select order_status Status,Order_ID OID,Delivery_date Date
from ordertable
inner join bill ON ordertable.order_id = bill.Order_id
and I got this error
Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'Order_ID'.
I know that order_id is in both tables but how I can solve this And also when I remove it error gone but in the result I see only two columns for Status and Date but not OID and any data from bill how I can do this ?