Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Joins two tables using sql

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-12-21 : 09:47:54
Imran writes "Hello there

This is Imran, will pray for you if u help me out with this problem

I have 2 tables

Developments
------------
->DevelopmentId - AutoNum
ProjectName


Development_Pictures
--------------------
->Auto
DevelopmentId
PicName
PicType

The two tables are linked by DevelopmentId. Each record in developments can have many related records in Development_Pictures.

Now i want all records from Developments
along with the PicName. The thing is that only to show
picName where the PicType is 'Big'

ProjectName, PicName

Thank You

where the "

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2005-12-21 : 11:29:44
Hi Imran,

I think better to learn some Basic SQL than pray for me !!

Select * from Developments
Where DevelopmentId in
(Select DevelopmentId from Development_Pictures where PicType = 'Big')



Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-12-21 : 12:58:30
Why the sub query?
Hi Imran,
Pray that you don't ever use expensive sub querires where you don't have to:

SELECT d.*, p.PicName FROM Developments d INNER JOIN Development_Pictures p on d.DevelopmentID = p.DevelopmentID WHERE p.PicType = 'Big'

Duane.
"It's a thankless job, but I've got a lot of Karma to burn off."
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-22 : 01:06:54
Learn SQL basics
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -