Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

SQL server join issues

  • 29-07-2006 8:19am
    #1
    Registered Users, Registered Users 2 Posts: 872 ✭✭✭


    Hi,

    I am trying to make a query using 3 tables.

    tables are feature_set,image_set and image_set_image

    the first part is to display all the feature_sets

    then i display image_sets if there are any related to feature_sets

    then i display image_set_images only if there are any related to image_Sets.

    select fs.feature_set_id,fs.name,fs.property_id,i.image_set_id,i.feature_set_id,isi.image_set_image_id,isi.image_url from dbo.feature_set fs
    inner join image_set i on fs.feature_set_id = i.feature_set_id
    left join image_set_image isi on i.image_set_id = isi.image_set_id

    where property_id = @property_id


    i know its way wrong and i think its to do with the joins.

    Basically i need all image_sets to appear even if there are no image_set_images.

    I hope i have made myself clear.

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Use Outerjoins instead of Inner Joins

    Inner Joins require a corresponding row based on the join criteria. ie join where id = id. So if they dont have an id it wont appear. Outer join will decide then .. Use left or right depending on which side of the expression you want the rows to appear.

    If you are using SQL Server, they you can use the view designer to help you with the queries


Advertisement