Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

I want to replace the the column value with other

$
0
0
Hello 

This is three table query.
Following is structure of the tables 

ClassClassification table
USE []
GO
/****** Object:  Table [dbo].[ClassClassification]    Script Date: 12/03/2013 12:02:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ClassClassification](
	[Class_Id] [int] IDENTITY(1,1) NOT NULL,
	[ClassNameValue] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ClassValue] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Para_Id] [int] NULL
) ON [PRIMARY]
 

SubClassName table

USE []
GO
/****** Object:  Table [dbo].[SubClassName]    Script Date: 12/03/2013 12:02:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SubClassName](
	[SubClass_Id] [int] IDENTITY(1,1) NOT NULL,
	[SubClassName] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Class_Id] [int] NOT NULL
) ON [PRIMARY]


MainClass Table

USE []
GO
/****** Object:  Table [dbo].[MainClassName]    Script Date: 12/03/2013 12:03:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MainClassName](
	[Class_Id] [int] IDENTITY(1,1) NOT NULL,
	[ClassName] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]


I fire the query. the following is query

select distinct SubClassName,s.Class_Id, m.ClassName
from SubClassName s,ClassClassification c, MainClassName m
where s.SubClassName =c.ClassNameValue and s.Class_Id=m.Class_Id

and i got an output

SubClassName   Class_Id  ClassName

carCompany	1	car
carModelName	2	carName
carVersion	2	carName

now i want to replace the column classNameValue from the ClassClasification as ClassName where SubClassName is same as classNameValue

reply


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>