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
 Problem with select statement query..

Author  Topic 

bluestar
Posting Yak Master

133 Posts

Posted - 2009-01-15 : 11:15:36
hello

I have a table named Linkage which will display external and internal linkages in a document.External linkages means user will create a link say www.yahoo.com.While creating internal element user will choose from system elements and creates its internal linkage which can be withing the same document or some different document

I have got 2 tables
Table Linkage and table SystemElement

Table linkage have following columns
LinkageTitleText text
SystemElementFrom int
SystemElementTo int
Hyperlink ---this is for external linkage

Table SystemElement
SystemElementID int
SystemElementTitleText text

SystemElementFrom and SystemElementTo are nothing but SystemElementID's.which are also in SystemElement Table.

Now I want to write a query which will display both Internal link---SystemElementTitleText and External link --Hyperlink.

To display SystemElementTitleText I am writing the following query
Select s.SystemElementTitleText,s.SystemElementID,l.SystemElementLinkageID,l.LinkageTitleText,l.LinkageDescriptionText,l.LinkageFromType,l.LinkageToType,l.SystemElementFrom,l.SystemElementTo From SystemElement s,Linkage l where s.SystemElementID=l.SystemElementTo

And to display Hyperlink,following query
Select * From Linkage.

I want both the parameters Hyperlink and SystemElementTitleText to display in result so I am doing Union of 2 select statement.But I am not getting the result.I even tried with JOIN ,but still in vain.


Please help!!!!!!

Thank You

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-15 : 23:39:53
[code]select l.*,se1.SystemElementTitleText AS FromLink,se2.SystemElementTitleText AS ToLink
from linkage l
join SystemElement se1
ON se1.SystemElementID=l.SystemElementFrom
join SystemElement se2
ON se2.SystemElementID=l.SystemElementTo[/code]
Go to Top of Page
   

- Advertisement -