How to write query to Delete the records in child table
and corresponding records in parent table
Answers were Sorted based on User's Feedback
Answer / vaishali
delete from child_table, parent_table where
child_table.parent_id=parent_table.parent_id
| Is This Answer Correct ? | 14 Yes | 26 No |
Can another user execute your local temporary stored procedures?
What is the sql server agent?
What is mscorsvw.exe - process - microsoft .net framework ngen?
* CREATE TABLE [dbo].[t_Colors]([ColorId] [int] NOT NULL,[ColorName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [ColorDesc] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[ColorIndex] [int] NULL) ON [PRIMARY] GO * insert into [t_Colors] values(101,'Red','',1) insert into [t_Colors] values(101,'Red1','',2) insert into [t_Colors] values(102,'Blue','',1) insert into [t_Colors] values(102,'Blue1','',2) insert into [t_Colors] values(102,'Blue2','',3) * In this table i need to delete DELETE FROM t_Colors WHERE ColorIndex=1 AND ColorId=102 After delete above condition i need to update the ColorIndex set to 1 for Blue1[ColorName] and 2 for Blue2[ColorName] select * from [t_Colors] Note:- how can i get updates the ColorIndex values after delete. for example we need to update Blue1 ColorIndex set to 1 and Blue2 ColorIndex set to 2
Difference between Function and Procedure-in general?
What is a join in sql?
What is a self join in sql server?
Explain the truncate command? : SQL Server Architecture
Difference between report and query parameter. Why do we need different type of parameter?
How to loop through result set objects using odbc_fetch_row()?
What are the main sources of data?
How to loop through the result set with @@fetch_status?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)