x
login about faq Site discussion (meta-askssc)

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.

more ▼

asked Apr 19 '12 at 08:05 AM in Default

sand143eep gravatar image

sand143eep
541 4 12 23

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

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?).

more ▼

answered Apr 19 '12 at 08:14 AM

WilliamD gravatar image

WilliamD
25.3k 16 18 41

thanks actually the table_kfc_role was not clearly related which thrown error.

Apr 19 '12 at 09:05 AM sand143eep
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.

Apr 19 '12 at 09:09 AM sand143eep

If that is the case, please mark this question as answered so we all know you have been helped out.

Apr 19 '12 at 09:22 AM WilliamD

never mind, I marked it as answered.

Apr 19 '12 at 09:51 AM Grant Fritchey ♦♦
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x1834

asked: Apr 19 '12 at 08:05 AM

Seen: 226 times

Last Updated: Apr 19 '12 at 09:51 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.