none
ambiguous column name sql server

    Question

  • i have sql query like that, when i execute this query i get the following error

    Msg 205, Level 16, State 1, Line 1
    Ambiguous column name 'active_id'.

    select user_no, user_name, active_id, active_name, payment_detail
    from table1
    join table2
    on table2.job_id = table1.attend_1
    join table3
    on table3.company_id = table2.company_id
    join table4.active_id = table1 = active_id

    any idea? how could i solve this?

    thank you so much


    • Edited by Drake6188 Thursday, March 07, 2013 4:18 PM
    Thursday, March 07, 2013 4:16 PM

Answers

All replies

  • HI,

    Try This :

    SELECT [user_no]
    	,[user_name]
    	,table1.active_id
    	,[active_name]
    	,[payment_detail]
    FROM table1
    JOIN table2 ON table2.job_id = table1.attend_1
    JOIN table3 ON table3.company_id = table2.company_id
    JOIN table4.active_id = table1.active_id

    http://simplesqlserver.wordpress.com/


    Dj's | Please mark as answered or vote helpful if this post help resolved your issue. Thanks!


    Thursday, March 07, 2013 4:20 PM
  • HI,

    Try This :

    SELECT [user_no]
    	,[user_name]
    	,table1.active_id
    	,[active_name]
    	,[payment_detail]
    FROM table1
    JOIN table2 ON table2.job_id = table1.attend_1
    JOIN table3 ON table3.company_id = table2.company_id
    JOIN table4.active_id = table1.active_id

    http://simplesqlserver.wordpress.com/


    Dj's | Please mark as answered or vote helpful if this post help resolved your issue. Thanks!


    thank you so much bro.. it's helpful to me :)

    regards

    Thursday, March 07, 2013 4:26 PM
  • Just a minor addition/correction. Need to change last line on DJ's SQL reply to:

    "JOIN table4 ON table4.active_id = table1.active_id"


    Please mark as answered or vote helpful if this post help resolved your issue. Thanks!

    k r o o t z


    Thursday, March 07, 2013 5:39 PM