View previous topic :: View next topic
|
Author |
Message |
vighnesh_r
New User
Joined: 23 Aug 2006 Posts: 14
|
|
|
|
Suppose there are 2 tables A and B. Can i delete a particular row corresponding to a value from both tables using a single query ???
P.S. don't need delete cascade as it will delete rows from all tables(even the ones from which i don't want to delete it )
TIA |
|
Back to top |
|
|
wanderer
Active User
Joined: 05 Feb 2007 Posts: 199 Location: Sri Lanka
|
|
|
|
I don't think this is possible. Could you explain why you can't use two separate statements to delete from two different tables? |
|
Back to top |
|
|
ragganga
New User
Joined: 22 Jan 2007 Posts: 18 Location: bangalore
|
|
|
|
Hi Vighnesh,
Using Subquery it is possible.
Regards
Raghu |
|
Back to top |
|
|
Prajesh_v_p
Active User
Joined: 24 May 2006 Posts: 133 Location: India
|
|
|
|
To add to what raghu told, you can have an exist check in where clause with a correlted subquery so that exist returns true only when you find a condition match in you table B. |
|
Back to top |
|
|
wanderer
Active User
Joined: 05 Feb 2007 Posts: 199 Location: Sri Lanka
|
|
|
|
Prajesh_v_p wrote: |
To add to what raghu told, you can have an exist check in where clause with a correlted subquery so that exist returns true only when you find a condition match in you table B. |
He wants the same query to delete the row from table B as well. Could you please provide a sample query that will do what you just said?
thanks! |
|
Back to top |
|
|
ragganga
New User
Joined: 22 Jan 2007 Posts: 18 Location: bangalore
|
|
|
|
Hi Wanderer,
Have you read question properly what vighnesh asked
Can i delete a particular row corresponding to a value from both tables using a single query ???
To my undestanding about question
He want to delete a record in Table A using a value from Table B or vise varsa.
singe Query means in between EXEQ SQL and END EXEQ
If i am wrong, Please correct me
Regards
Raghu |
|
Back to top |
|
|
wanderer
Active User
Joined: 05 Feb 2007 Posts: 199 Location: Sri Lanka
|
|
|
|
ragganga wrote: |
Have you read question properly what vighnesh asked
Can i delete a particular row corresponding to a value from both tables using a single query ???
To my undestanding about question
He want to delete a record in Table A using a value from Table B or vise varsa.
|
No, I don't think so. He hasn't mentioned anything like 'vice versa'. That is your assumption. And if you read his note under "P.S.", the 'cascade' thing clearly means that he intends to delete from both tables.
Quote: |
singe Query means in between EXEQ SQL and END EXEQ
If i am wrong, Please correct me
Regards
Raghu |
That is not true.
Anyway, I doubt the original poster is going to come back and explain what he wants. |
|
Back to top |
|
|
ragganga
New User
Joined: 22 Jan 2007 Posts: 18 Location: bangalore
|
|
|
|
P.S. don't need delete cascade as it will delete rows from all tables
Quote: |
In 'P.S' Have you noticed 'Don't need delete Casacade' what it means and he already given the function of Cascade (as it will delete rows from all table)
My dear friend, what are writing
Wanderer wrote
Quote: |
the 'cascade' thing clearly means that he intends to delete from both tables. |
In 'P.S' he already mention in bracket he doesn't want to delete from other Table
(even the ones from which i don't want to delete it ) |
Thanks |
|
Back to top |
|
|
vighnesh_r
New User
Joined: 23 Aug 2006 Posts: 14
|
|
|
|
Hi All,
Sorry for the long absence
Perhaps i didn't explain it clearly enough. My intention was to delete rows from both tables A and B using a single query. |
|
Back to top |
|
|
vighnesh_r
New User
Joined: 23 Aug 2006 Posts: 14
|
|
|
|
wanderer wrote: |
I don't think this is possible. Could you explain why you can't use two separate statements to delete from two different tables? |
No particular reason ... My friend and i were having a discussion if such a thing could be done, thought i'd ask around |
|
Back to top |
|
|
vini_IBM
New User
Joined: 16 Apr 2007 Posts: 3 Location: Bangalore, INDIA
|
|
|
|
As per my basic knowledge in SQL & DB2,
INSERT,UPDATE & DELETE* can be done on only one table in a given query. Conditions apply for DELETE when RI is there -
Please correct me if am wrong. |
|
Back to top |
|
|
|