PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Select Statements

Reply

Select Statements

 
Thread Tools Rate Thread
Old 03-01-2007, 11:30 AM   #1
TheDude5B
Guest
 
Posts: n/a
Default Select Statements


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...

  Reply With Quote
Old 03-01-2007, 11:33 AM   #2
TheDude5B
Guest
 
Posts: n/a
Default Re: Select Statements

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

  Reply With Quote
Old 03-01-2007, 12:34 PM   #3
Goofy
Guest
 
Posts: n/a
Default Re: Select Statements

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



  Reply With Quote
Old 03-01-2007, 01:08 PM   #4
TheDude5B
Guest
 
Posts: n/a
Default Re: Select Statements

Thanks Goofy, that worked just great.

  Reply With Quote
Old 03-01-2007, 02:11 PM   #5
Goofy
Guest
 
Posts: n/a
Default Re: Select Statements

Your welcome


"TheDude5B" <timbjames@gmail.com> wrote in message
news:1167829721.925711.12860@s34g2000cwa.googlegroups.com...
> Thanks Goofy, that worked just great.
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off