Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8601345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:49:13+00:00 2026-06-12T01:49:13+00:00

I get an ambiguous column name error with this query (InvoiceID). I can’t figure

  • 0

I get an ambiguous column name error with this query (InvoiceID). I can’t figure out why. They all seem to be joined correctly so why doesn’t SSMS know to display VendorID?

Query:

SELECT 
    VendorName, InvoiceID, InvoiceSequence, InvoiceLineItemAmount
FROM Vendors 
JOIN Invoices ON (Vendors.VendorID = Invoices.VendorID)
JOIN InvoiceLineItems ON (Invoices.InvoiceID = InvoiceLineItems.InvoiceID)
WHERE  
    Invoices.InvoiceID IN
        (SELECT InvoiceSequence 
         FROM InvoiceLineItems
         WHERE InvoiceSequence > 1)
ORDER BY 
    VendorName, InvoiceID, InvoiceSequence, InvoiceLineItemAmount
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:49:14+00:00Added an answer on June 12, 2026 at 1:49 am

    We face this error when we are selecting data from more than one tables by joining tables and at least one of the selected columns (it will also happen when use * to select all columns) exist with same name in more than one tables (our selected/joined tables). In that case we must have to specify from which table we are selecting out column.

    Following is a an example solution implementation of concept explained above

    I think you have ambiguity only in InvoiceID that exists both in InvoiceLineItems and Invoices Other fields seem distinct. So try This

    I just replace InvoiceID with Invoices.InvoiceID

       SELECT 
            VendorName, Invoices.InvoiceID, InvoiceSequence, InvoiceLineItemAmount
        FROM Vendors 
        JOIN Invoices ON (Vendors.VendorID = Invoices.VendorID)
        JOIN InvoiceLineItems ON (Invoices.InvoiceID = InvoiceLineItems.InvoiceID)
        WHERE  
            Invoices.InvoiceID IN
                (SELECT InvoiceSequence 
                 FROM InvoiceLineItems
                 WHERE InvoiceSequence > 1)
        ORDER BY 
            VendorName, Invoices.InvoiceID, InvoiceSequence, InvoiceLineItemAmount
    

    You can use tablename.columnnae for all columns (in selection,where,group by and order by) without using any alias. However you can use an alias as guided by other answers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't see what is wrong with this query. I get an error saying:
I get this error while accessing a php script: W/System.err: Error reading from ./org/apache/harmony/awt/www/content/text/html.class
I have figured out most of my SQL query, but I seem to need
If i remove USING (nid,sid) , i get the column is ambigious error. I
I have this messy join query using 3 tables: SELECT p.idproduct, p.name, m.sust, p.desc,
How can I get C# to distinguish between ambiguous class types without having to
I get Compiler Error C2248 when i try to compile the following code: #include
I get the following error even when my JAVA_HOME is set correctly. C:\workspace-sts-2.8.0.RELEASE\JBClient\target>echo %JAVA_HOME%
I'm trying to select multiple rows over different tables but I can't get it
I need help with SQL Server Table Column. I´m trying to rename Column Name,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.