Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to combine a row from another table?

Author  Topic 

Delinda
Constraint Violating Yak Guru

315 Posts

Posted - 2009-10-18 : 11:35:42
Hi,

My table as follow,
tSysUser
UsID | SLvl | gCounter |
-------------------------------
ADMIN | 1 | N
OFFICER | 2 | N
.....
.....
.....

tSysPara
ImID | Linc
------------
S32 | 0
*tSysPara only contains 1 row and dont have any relationship with tSysUser


tSysLinc
sComp | Cout | CNam
---------------------
AMRU | HPT | BROKEN
*tSysLinc only contains 1 row and dont have any relationship with tSysUser

How my SQL look's like, to generate row as follow
UsID | SLvl | gCounter | ImID | Linc | sComp | Cout |CNam
--------------------------------------------------------------------
ADMIN | 1 | N | S32 | 0 | AMRU | HPT | BROKEN

Plese help

singularity
Posting Yak Master

153 Posts

Posted - 2009-10-18 : 13:16:35
select *
from tSysUser a
cross join tSysPara b
cross join tSysLinc c
Go to Top of Page

Delinda
Constraint Violating Yak Guru

315 Posts

Posted - 2009-10-18 : 14:58:30
quote:
Originally posted by singularity

select *
from tSysUser a
cross join tSysPara b
cross join tSysLinc c



if table tSysPara, as follow,
tSysPara
ImID | Linc
------------
S32 | 0

how to filter in cross join tSysPara? let's say i want to select Linc only?
Go to Top of Page

singularity
Posting Yak Master

153 Posts

Posted - 2009-10-19 : 20:50:00

Just specify the columns you want from each table:


select a.UsID, a.SLvl, a.gCounter, b.Linc, c.sComp c.Cout, c.CNam
from tSysUser a
cross join tSysPara b
cross join tSysLinc c
Go to Top of Page
   

- Advertisement -