sql - Return all rows from one table regardless of no data in other tables. Using Where Clause -
i have db handles reservations made against resources. i'm using ssrs 2008 r2
. i've made sure joins in visual designer showing rows on resources
table.
how can return rows resources
table regardless of data in other joining tables? i'm using where
clause parameters of start date , end date. these parameters refer dates on reservations
table. if remove where
clause resources
. need start date , end date included can search between 2 dates. thought if did left outer join on resources
table i'd resources. however, getting resources associated reservations made between start date , end date.
what doing wrong?
select
(rows here)
from _reservationsattributes right outer join _reservations on _reservationsattributes.reservationid = _reservations.reservationid right outer join _resources on _reservations.resourceid = _resources.resourceid left outer join _locationsattributes on _resources.locationid = _locationsattributes.locationid left outer join _locations on _resources.locationid = _locations.locationid left outer join _resourcesattributes on _resources.resourceid = _resourcesattributes.resourceid (_locationsattributes.[@33] = @distinct_premise) , (_reservations.startdate >= @start_date) , (_reservations.enddate <= dateadd(day, 1, @end_date)) order _locations.orderby, _resources.name
deconstruct query. start central table (_resources). add each of other tables in 1 @ time, where
conditions. make sure each step makes sense before adding next table in.
my guess - getting confused using both left outer
, right outer
joins. need schema sure.
Comments
Post a Comment