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
 General SQL Server Forums
 New to SQL Server Programming
 Relation in Two Tables....

Author  Topic 

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-04-02 : 02:40:04
Here With Me Some Problem i Have A table Which Conatians data As The columns name in rows and another table in which these are columns like,,,

Table:: MasterAll
sid scol sdecs
1 sname contain name
2 sadd contain add
3 sfname contain fname

and i have also other table like ,,,,,

Table :: DataALL

sid sname snamedesc sadd2 scadddesc sfname sfnamedesc
1 Ashish Some Data 353 EPIP Some Data Sh Vijay somedata
2 Some Data Some Data Some Data Some Data Some Data Some Data
3 Some Data Some Data Some Data Some Data Some Data Some Data


Mean For Every Row in Table:: MASTERALL Table ::DATAALL has 2 columns so i like to maintain some relation in these tables from which i like to extract all the data from
table :: DATALL when i select some value from table:: MASTERALL

like when i select in MasterALL table so i like to get back results from table DATAALL sname and snamedesc columns to return back,,,

May be i make u understand my problem ... i just want to get any relation in these tables so i extract data from these tables..
Thanks...

tosscrosby
Aged Yak Warrior

676 Posts

Posted - 2009-04-02 : 11:01:58
In reality, I think YOU need to tell us what the relationship is, it is your table and data. Secondly, some realistic data will help a little too (some data, some data just doesn't cut it). Just a quick glance, but is masterall.sid = dataall.sid? if so, will the following script do? I can't be certain because you haven't provided enough information of any value.

#1:
select m.sid, d.sname, d.snamedesc
from masterall m
left outer join dataall d
on m.sid = d.sid

OR

#2:
select m.sid, d.sname, d.snamedesc
from masterall m
left outer join dataall d
on m.sid = d.sid
and m.scol = d.sname

Although, based on your sample data, I don't think #2 works.

Terry

-- Procrastinate now!
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-04-03 : 00:08:52
I just want if in MASTERALL table i pass a variable from my FRont End Application called SName or masterall.sid=1 then i want to retrive all the records from the table DATAALL in the column SNAME ans SNAMDESC...

May be this time i make you understand what i want....

Thanks For Reply...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-04-03 : 13:02:31
sorry your description does make it clear still. can you at least give your expected output out of above sample data?
Go to Top of Page
   

- Advertisement -