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 2005 Forums
 Transact-SQL (2005)
 query help

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2007-07-25 : 06:00:24
table code is

CREATE TABLE [dbo].[category] (
[catid] [int] IDENTITY (1, 1) NOT NULL ,
[categoryname] [varchar] (150) COLLATE Hebrew_CI_AS NULL ,
[categoryimage] [char] (50) COLLATE Hebrew_CI_AS NULL ,
[categorydesc] [ntext] COLLATE Hebrew_CI_AS NULL ,
[metadesc] [char] (255) COLLATE Hebrew_CI_AS NULL ,
[metakeywords] [char] (255) COLLATE Hebrew_CI_AS NULL ,
[parentcatid] [int] NULL ,
[sortorder] [int] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


now I have
select catid,categoryname from category where parentcategory<>0

now what I really want it to concatenate the category name with it's parent name so it would show for categoryname parentname+categoryname as categoryname

is this possible with a join?

but

salavat_a
Starting Member

5 Posts

Posted - 2007-07-25 : 06:53:43
I would try:

select catC.catid, catP.categoryname + catC.categoryname from category catC INNER JOIN category catP on catP.catID = catC.parentcategory
Go to Top of Page
   

- Advertisement -