question

sand143eep avatar image
sand143eep asked

problem in Joining the tables

Hello all i am executing the following code: SELECT A.KFC_ID, A.Date_of_request, B.plc_Name_long, E.Broker_GivenName, E.Email FROM table_KFC_KFC A, table_Broker E INNER JOIN table_plc B ON A.plc_id = B.plc_id INNER JOIN table_KFC_role R ON E.Broker_ID = R.Broker_ID WHERE R.role_id IN (100, 145, 698, 775, 1) when executed the following query then i am getting the following Error: Msg 4104, Level 16, State 1, Line 1 The multi-part identifier "A.plc_id" could not be bound. please suggest how can i rectify this error.
sql-server-2005
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
WilliamD avatar image
WilliamD answered
The error means that the column '`plc_id`' is not present in the table '`table_KFC_KFC`'. Make sure that the join to '`table_plc`' is using the correct column(s). Also reconsider the query in regards to the table '`table_Broker`' - you are using the old style join syntax (is the cross join onto '`table_KFC_KFC`' desired?).
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sand143eep avatar image sand143eep commented ·
thanks actually the table_kfc_role was not clearly related which thrown error.
0 Likes 0 ·
sand143eep avatar image sand143eep commented ·
SELECT distinct A.KFC_ID, A.Date_of_request, B.plc_Name_long, E.Broker_GivenName AS [PM Name], E.Email FROM table_KFC_KFC A INNER JOIN table_plc B ON A.plc_id = B.plc_id INNER JOIN table_KFC_role R on r.KFC_header_id = a.KFC_header_id INNER JOIN table_Broker E ON E.Broker_ID = R.Broker_ID WHERE R.role_id in(100,145,698,775,1) this code when i added it executed successfully.
0 Likes 0 ·
WilliamD avatar image WilliamD commented ·
If that is the case, please mark this question as answered so we all know you have been helped out.
0 Likes 0 ·
Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
never mind, I marked it as answered.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.