|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with SQL Query
<i><b>Originally posted by : Patrick (spamboy@dugans.com)</b></i><br />I have a database with three tables, Faculty, Degrees and Images. Here's my SQL query right now:<br /><br />SELECT Faculty.*,Degrees.Degree,Images.ImgName FROM Faculty,Degrees,Images<br />WHERE Faculty.FacID=7 AND Degrees.FacID=7 AND Images.FacID = 7<br /><br />This successfully pulls all the info for this faculty member with id 7, and all of the member's degrees and images from the Degrees and Images tables respectively. Here's the catch. There might not be any degrees or images with an id of 7. How can I write a SQL statement that will pull all a faculty member's data, and will give images and degrees if they exist?
|
|
#2
|
|||
|
|||
|
<i><b>Originally posted by : iyyappan n iyer (iyyappan_n_i@hotmail.com)</b></i><br /><br /><br /><br />select * from faculty,degrees,images where (faculty.facid=7 ) or (faculty.facid=7 and degrees.facid = 7 and images.facid=7)<br /><br /><br />
|
|
#3
|
|||
|
|||
|
SELECT Faculty.*,Degrees.Degree,Images.ImgName FROM Faculty,Degrees,Images
WHERE Faculty.FacID= Degrees.FacID AND Images.FacID = Faculty.FacID AND Faculty.FacID = 7 |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Help with SQL Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|