PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Select Statements
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Select Statements
![]() |
Select Statements |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
I have two tables. One table contains the information about the object, and then the other table contains the objects ID and then the ID of where this object is allocated to. table one Object: ObjectID, ObjectName. table two Allocated: siteID, ObjectID. now the ObjectID in table two will appear many times depending on how many sites it is allocated to. So here lyes my problem. I want to be able to check table two to see which Objects are allocated, and then display the Object Information from table one. I can select the data just now, but because the Object appears in table two multiple times, it will display the Object information multiple times also. I only want it to be displayed once. Is there some sort of IF statement which I can implement into my SQL Stored Procedure which says something like SELECT ONE tblOne.ObjectID, tblOne.ObjectName FROM tblOne INNER JOIN tblOne ON tblTwo.ObjectID = tblOne.ObjectID ? my advanced SQL is not as good as it should be, so it would be a great help if someone knows how I could implement this. Thanks... |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Just as an example.
table one. ObjectID ObjectName 1 Something 2 SomethingElse table two SiteID ObjectID 1 1 2 1 3 1 4 1 5 2 6 2 7 1 So i would only want to display the details for Object 1 because it has been allocated to a site(s). |
|
|
|
#3 |
|
Guest
Posts: n/a
|
How about
Select Distinct Object1.ID from TableOne where . . . . . "TheDude5B" <timbjames@gmail.com> wrote in message news:1167824017.811166.57150@v33g2000cwv.googlegroups.com... > Just as an example. > > table one. > > ObjectID ObjectName > 1 Something > 2 SomethingElse > > table two > > SiteID ObjectID > 1 1 > 2 1 > 3 1 > 4 1 > 5 2 > 6 2 > 7 1 > > So i would only want to display the details for Object 1 because it has > been allocated to a site(s). > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Thanks Goofy, that worked just great.
|
|
|
|
#5 |
|
Guest
Posts: n/a
|
Your welcome
"TheDude5B" <timbjames@gmail.com> wrote in message news:1167829721.925711.12860@s34g2000cwa.googlegroups.com... > Thanks Goofy, that worked just great. > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

