Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQL JOIN on same Table

1 view
Skip to first unread message

Ken Ashton

unread,
Oct 28, 2010, 3:29:24 PM10/28/10
to
I've got confused trying to join on same table (for the first time).
Table is manufacturer ID and Name, want to indicate if manufacturer
has parent company,
Parent will be in the list anyway (I didn't want another table for
'parent companies'

Record is [ID} [PID] [txtName]

Trying for a 3 column list which (PID is hidden) which only shows
'txtname for the parent' when ID<>CID (or CID=0)

ID txtName txtName PID
-- ------- ------- ---
1 HP 1
2 Dell 2
3 Compaq HP 1
4 Cisco 4

After a getrows, I intended to loop thro' the array

...
print arr(0, i) ' ID Column
print arr(2, i) ' Manufacturer
if arr(0,1)<>arr(1,1) print arr(3, i)
....

Can any of you guys suggest a SELECT query that will allow me to do
this.

Many Thanks in advance.

Ken Ashton


--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

footy

unread,
Nov 1, 2010, 2:55:49 PM11/1/10
to
Ken Ashton wrote:
> I've got confused trying to join on same table (for the first time).
> Table is manufacturer ID and Name, want to indicate if manufacturer
> has parent company,
> Parent will be in the list anyway (I didn't want another table for
> 'parent companies'
>
> Record is [ID} [PID] [txtName]
>
> Trying for a 3 column list which (PID is hidden) which only shows
> 'txtname for the parent' when ID<>CID (or CID=0)
>
> ID txtName txtName PID
> -- ------- ------- ---
> 1 HP 1
> 2 Dell 2
> 3 Compaq HP 1
> 4 Cisco 4
>
> After a getrows, I intended to loop thro' the array
>
> ...
> print arr(0, i) ' ID Column
> print arr(2, i) ' Manufacturer
> if arr(0,1)<>arr(1,1) print arr(3, i)
> ....
>
> Can any of you guys suggest a SELECT query that will allow me to do
> this.

So silent about this case :(
But, which one is more important to you - get join table itself or this
conditional output?

0 new messages