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
 join and where
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Lenjaku
Starting Member

13 Posts

Posted - 07/19/2012 :  03:35:45  Show Profile  Reply with Quote
I know how to join (I think I need inner join)
But I dunno how to add where condition to it (if needed)

Basically I need to get a field from table2 which is the result of a condition of field from table 1 and another field from table2.

And I need other field to simply b displayed as well.
I will give an example of the fields I need only.

Grade:
grades
grade_date
Lesson_ID <---fk

Lesson:
ID<----should this is lesson_id , it is the pk of this table
Lesson_name <---this is what I want to b displayed eventually.


So waht I want is to display grades,grade_date as is and to display
Lesson name, where Grade.Lesson_ID=Lesson_ID.

I tried this:
SELECT [Grade_date], [Grade_grade] , [Lesson_name] , [Lesson_name] FROM [grade] INNER JOIN [Lesson] ON [grade.Lesson_ID=Lesson.ID]

Didn;t work though :S

Lenjaku
Starting Member

13 Posts

Posted - 07/19/2012 :  03:36:58  Show Profile  Reply with Quote
Ignore the 'should' word a thte second table (lessons)
Buu why can;t I edit -.-
Go to Top of Page

Lenjaku
Starting Member

13 Posts

Posted - 07/19/2012 :  04:24:35  Show Profile  Reply with Quote
Ok I did get it right but the tool I was using didn;t accept this writing it needed
Lesson_ID and ID isntead of
grade.Lesson_ID and Lesson.ID

Meh :S atleast I know I was right :D
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.05 seconds. Powered By: Snitz Forums 2000