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.
| Author |
Topic |
|
gisaac
Starting Member
1 Post |
Posted - 2005-11-10 : 21:29:45
|
| I am creating a simple stored procedure. I want to merge data from 3 tables.1. schedule_rohan = contains hours available in the schedule according to day2. appointments_rohan = contains appointments3. patients_rohan = contains patientsFor example, I have the following as my select statement:SELECT *FROMappointments_rohanJOIN schedule_rohan ONappointments_rohan.st_time=schedule_rohan.hourJOIN patients_rohan ONappointments_rohan.name=patients_rohan.NoDossierWHERE appointments_rohan.cal_date = '5/19/2004' ANDschedule_rohan.day = 4ORDER BY st_time ASCIt only produces a data set by matching the available hours from the schedule for that day of the week to the appointment (st_time) for that date in the appointments table.How can I return a data set that matches the hours in the schedule with the appointments for that day, but also shows a null value for hours that don't have an appointment in the appointments table (appointments_rohan)? It seems that I could use a RIGHT OUTER JOIN, but it doesn't return the data set I want.Thanks,Gary |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-11 : 00:12:27
|
| Post table structures, some sample data and the result you wantMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|