Select Statements

  • Thread starter Thread starter TheDude5B
  • Start date Start date
T

TheDude5B

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...
 
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).
 
Back
Top