---
title: "Error while join table in SQL"  
description: "Error while join table in SQL"  
author: "Anonymous User"  
published: 2014-08-21  
updated: 2014-08-21  
canonical: https://www.mindstick.com/forum/2068/error-while-join-table-in-sql  
category: "mssql server"  
tags: ["mssql server"]  
reading_time: 1 minute  

---

# Error while join table in SQL

I have [two tables](https://www.mindstick.com/forum/159646/how-to-join-two-tables-in-oracle-to-get-single-line-results) that have [relationship](https://yourviews.mindstick.com/view/80819/live-in-relationship-protecting-the-right-to-live-together) with [UserName](https://www.mindstick.com/forum/12798/there-is-no-viewdata-item-of-type-ienumerable-selectlistitem-that-has-the-key-username) field. Based on UserName column, I want to get ID from CarReserve table. Here is my SQL statement:

SELECT CarReserve.ID

FROM CarReserve

[INNER JOIN](https://www.mindstick.com/forum/33572/sql-inner-join-keyword) aspnet_Users ON CarReserve.UserName = aspnet_Users.UserName

WHERE UserName = @UserName

Unfortunately, I [am getting](https://www.mindstick.com/forum/34179/i-am-getting-error-while-assigning-the-data-to-the-array-list) this [warning](https://answers.mindstick.com/blog/77/psychological-risks-of-ai-chatbots-what-experts-are-warning-about):

[Ambiguous column](https://www.mindstick.com/forum/159609/explain-the-significance-of-an-ambiguous-column-reference-error) name "UserName"

Can [anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) here tell me what is wrong with my statement?

## Replies

### Reply by Sumit Kesarwani

Hi Jay, try this:

SELECT CarReserve.ID

FROM CarReserve

INNER JOIN aspnet_Users ON CarReserve.UserName = aspnet_Users.UserName

WHERE aspnet_Users.UserName = @UserName


---

Original Source: https://www.mindstick.com/forum/2068/error-while-join-table-in-sql

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
