Select from 2 tables

  • I have 2 tables: Issues and Attachement

    Issue table contains 10 records and has the following design

    IssueId

    IssueName

    IssueDate

    IssueDescription

    Attachement contains 5 records table has the follwing desin

    IDAttachement

    Filename

    IssueID

    I want to select everything from the 2 tables total 10 records as the following if fiename not exsits display No files

    IssueID IssueName Filename

    1 Issue1 file1

    2 Issue2 Nofile

    3 Issue3 Nofile

    4 Issue4 Nofile

    5 Issue5 Nofile

    6 Issue 6 file6

    7 Issue 7 file 7

    8 Issue 8 file 8

    9 Issue 9 file 9

    10 Issue 10 Nofile

    please help me to display Nofile if there was no attachement for the issue

    I need the SQL select Query Please help

  • you will want to use an outer join (depends which way round you reference the tables as to a left or right) with the isnull functionality

  • can you please write the select for me

  • surely this will diminish the learning aspect

    use books online and look at the isnull function and outter joins

    this is a very simple statement you are after

  • Ok BABA

    I will look it myself but i am not gonna mark your post as answered;-)

  • need your help

  • post your statement so far and I will see if your on the right track or not.

  • samiroko (7/4/2011)


    Ok BABA

    I will look it myself but i am not gonna mark your post as answered;-)

    FYI... there is no such function on these forums 😀

    /T

  • common guys I need a solution

  • as others say, you want to do a outer join perhaps like the below example

    you can find examples on books online, w3schools etc

    select column,column2,column3

    from tableA tblA(nolock)

    left outer join tableB tblB(nolock) on tblA.collum=tablB.colmun

    ***The first step is always the hardest *******

  • select * from issues i

    left outer join attachments a

    on i.id = a .id

    this is similar to what you what , if your looking for spoon feeding , you need to wait till a better person than me comes along

    Jayanth Kurup[/url]

  • Jayanth_Kurup (7/4/2011)


    select * from issues i

    left outer join attachments a

    on i.id = a .id

    this is similar to what you what , if your looking for spoon feeding , you need to wait till a better person than me comes along

    it seems we are in the same boat, there is nothing like learning the solution for yourself, that way you can say you have completed the goal instead of someone telling you how to do it where you dont learn

  • add in here some code to create some representative data or what data you want and i will pop you some SQL

    ***The first step is always the hardest *******

  • Oh please! Do your OWN homework!!!! This is stupid easy stuff that you can get help with from Books On Line (BOL)... It's not our fault you're too lazy to do your own homework!

  • I will not go so far as to yell at you, but this is a question which answer can be found almost every lesson 2 of sql.

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic. Login to reply