SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Newbie stuck on INNER JOIN
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

muschamp
Starting Member

USA
14 Posts

Posted - 05/13/2008 :  12:22:24  Show Profile  Reply with Quote
This is my query:

SELECT aircraft_id, maximum_speed_mph
FROM us INNER JOIN rus
ON us.aircraft_id = rus.aircraft_id
WHERE maximum_speed_mph > ‘1000’

This is my error:

Msg 209, level 16, State 1, Line 4
Ambiguous column name ‘maximum_speed_mph’
Msg 209, level 16, State 1, Line 4
Ambiguous column name ‘Aircraft_id’
Msg 209, level 16, State 1, Line 4
Ambiguous column name ‘maximum_speed_mph’


Thanks for the help


US Navy - We are fueled, armed, and go for launch.

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 05/13/2008 :  12:26:21  Show Profile  Reply with Quote
SELECT {us/rus}.aircraft_id, {us/rus}.maximum_speed_mph
FROM us INNER JOIN rus
ON us.aircraft_id = rus.aircraft_id
WHERE {us/rus}.maximum_speed_mph > ‘1000’

give any one alias for column names (based on what values you want)
Go to Top of Page

muschamp
Starting Member

USA
14 Posts

Posted - 05/13/2008 :  12:32:57  Show Profile  Reply with Quote
I'm using SQL Express 2005

I tried it, but still getting error message.

Msg 102, Level 15, State 1, Liine 1
Incorrect syntax near '/'

US Navy - We are fueled, armed, and go for launch.
Go to Top of Page

sakets_2000
Flowing Fount of Yak Knowledge

India
1472 Posts

Posted - 05/13/2008 :  12:42:07  Show Profile  Reply with Quote
As indicated in the error messages,column names:--
maximum_speed_mph,Aircraft_id are common in the 2 tables used.

So specify wherever you are using these column names,as to which table you mean.

This specification can be done by prefixing the name of the table before the column.
So instead of writing maximum_speed_mph,write rus.maximum_speed_mph or us.maximum_speed_mph.
Go to Top of Page

Van
Constraint Violating Yak Guru

458 Posts

Posted - 05/13/2008 :  12:42:19  Show Profile  Reply with Quote
It appears that the fields [aircraft_id] and [maximum_speed_mph] exist in both the [us] and [rus] tables. SQL Server doesn't know which table you want it from so you have to tell SQL Server which table to get it from. So instead of us/rus, choose us or rus (the one you want). That's what visach16 was illustrating. He didn't mean actually make it {us/rus} but to choose one.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 05/13/2008 :  12:45:31  Show Profile  Reply with Quote
quote:
Originally posted by muschamp

I'm using SQL Express 2005

I tried it, but still getting error message.

Msg 102, Level 15, State 1, Liine 1
Incorrect syntax near '/'

US Navy - We are fueled, armed, and go for launch.


i put / to use either of us or rus as i dont know which values you want either use us.column or rus.column
Go to Top of Page

muschamp
Starting Member

USA
14 Posts

Posted - 05/13/2008 :  14:11:16  Show Profile  Reply with Quote
I didn’t have a clear understanding of an INNER JOIN. I was trying to combine and compare the same data from two different tables. On the bright side you helped a newbie to get one step closer to know what he’s doing.

Thanks for the help!


US Navy - We are fueled, armed, and go for launch.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 05/13/2008 :  14:14:33  Show Profile  Reply with Quote
quote:
Originally posted by muschamp

I didn’t have a clear understanding of an INNER JOIN. I was trying to combine and compare the same data from two different tables. On the bright side you helped a newbie to get one step closer to know what he’s doing.

Thanks for the help!


US Navy - We are fueled, armed, and go for launch.


Did you get your result? Suggest you to go through JOINs in books online to get more idea.
Go to Top of Page

muschamp
Starting Member

USA
14 Posts

Posted - 05/13/2008 :  15:53:00  Show Profile  Reply with Quote
Our software engineer walked in and in lighted with how INNER JOINS work and what they are used for.

US Navy - We are fueled, armed, and go for launch.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000