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 6706855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:34:10+00:00 2026-05-26T07:34:10+00:00

If I want to write a query with a simple join, I can do

  • 0

If I want to write a query with a simple join, I can do this:

select * from customer c
join order o
on c.customerid = o.customerid
where c.customerid = 100

and it all works fine. In this query, is there a reason why I have to specify a table alias – ie. c.customerid? Why can’t I just write this:

select * from customer c
join order o
on c.customerid = o.customerid
where customerid = 100

I get the error Ambiguous column name 'customerid'. In this case, where there’s only one column in the WHERE clause and it’s the column on which I’m JOINing, is this actually “ambiguous”? Or is it just to comply with the ansi-standard (I’m guessing here – I don’t know if it does comply) and to encourage good coding conventions?

  • 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-05-26T07:34:10+00:00Added an answer on May 26, 2026 at 7:34 am

    For your specific example I can’t think of any circumstances in which it would make a difference. However for an INNER JOIN on a string column it could do as below.

    DECLARE @customer TABLE
    (customerid CHAR(3) COLLATE Latin1_General_CI_AS)
    
    INSERT INTO @customer VALUES('FOO');
    
    DECLARE @order TABLE
    (customerid CHAR(3) COLLATE Latin1_General_CS_AS)
    
    INSERT INTO @order VALUES('FOO');
    
    
    SELECT * 
    FROM @customer c
    JOIN @order o
    ON c.customerid = o.customerid COLLATE Latin1_General_CS_AS
    WHERE c.customerid = 'Foo' /*Returns 1 row*/
    
    SELECT * 
    FROM @customer c
    JOIN @order o
    ON c.customerid = o.customerid COLLATE Latin1_General_CS_AS
    WHERE o.customerid = 'Foo' /*Returns 0 rows*/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a query like this: SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order
I want to write a query to select from a table all rows with
I want to write a LINQ to Entity query which does order by ascending
For this question, we want to avoid having to write a special query since
In MySQL, I have a simple "SELECT * FROM foo" query. I would like
I have a simple query: select * from countries with the following results: country_name
I am using SQL Server 2000 and want to write a simple query to
I'm trying to write a simple query in sqlite with a self join. I
i want to write a query with Full-Text-Search on a column with varbinary(max) type
I want to write an SQL query using the LIKE keyword. It should search

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.