dbTalk Databases Forums  

Delete statement

comp.databases comp.databases


Discuss Delete statement in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
cmems4u@gmail.com
 
Posts: n/a

Default Delete statement - 05-14-2008 , 12:53 AM






Hi all,
Is it possible to perform delete operation with the table join like
this?

'DELETE FROM temp INNER JOIN request_tbl ON temp.ID = request_tbl.ID
WHERE temp.name LIKE request_tbl.name;'

Reply With Quote
  #2  
Old   
Ed Prochak
 
Posts: n/a

Default Re: Delete statement - 05-14-2008 , 06:49 AM






On May 14, 1:53 am, cmem... (AT) gmail (DOT) com wrote:
Quote:
Hi all,
Is it possible to perform delete operation with the table join like
this?

'DELETE FROM temp INNER JOIN request_tbl ON temp.ID = request_tbl.ID
WHERE temp.name LIKE request_tbl.name;'
Think about it for a moment. What do you get when you write:
temp INNER JOIN request_tbl ON temp.ID = request_tbl.ID
?
You no longer have a table you have a result set. Given that, what do
you think is the target of the DELETE?

Syntax of DELETE is

DELETE FROM <table name>
WHERE <predicate>

ASSUMING the temp table is the target of the delete something like
this works:
DELETE FROM temp where temp.ID IN
( select temp.ID FROM temp INNER JOIN request_tbl ON temp.ID =
request_tbl.ID
WHERE temp.name LIKE request_tbl.name ) ;

Have a good day,
Ed


Reply With Quote
  #3  
Old   
Ed Prochak
 
Posts: n/a

Default Re: Delete statement - 05-14-2008 , 06:49 AM



On May 14, 1:53 am, cmem... (AT) gmail (DOT) com wrote:
Quote:
Hi all,
Is it possible to perform delete operation with the table join like
this?

'DELETE FROM temp INNER JOIN request_tbl ON temp.ID = request_tbl.ID
WHERE temp.name LIKE request_tbl.name;'
Think about it for a moment. What do you get when you write:
temp INNER JOIN request_tbl ON temp.ID = request_tbl.ID
?
You no longer have a table you have a result set. Given that, what do
you think is the target of the DELETE?

Syntax of DELETE is

DELETE FROM <table name>
WHERE <predicate>

ASSUMING the temp table is the target of the delete something like
this works:
DELETE FROM temp where temp.ID IN
( select temp.ID FROM temp INNER JOIN request_tbl ON temp.ID =
request_tbl.ID
WHERE temp.name LIKE request_tbl.name ) ;

Have a good day,
Ed


Reply With Quote
  #4  
Old   
Ed Prochak
 
Posts: n/a

Default Re: Delete statement - 05-14-2008 , 06:49 AM



On May 14, 1:53 am, cmem... (AT) gmail (DOT) com wrote:
Quote:
Hi all,
Is it possible to perform delete operation with the table join like
this?

'DELETE FROM temp INNER JOIN request_tbl ON temp.ID = request_tbl.ID
WHERE temp.name LIKE request_tbl.name;'
Think about it for a moment. What do you get when you write:
temp INNER JOIN request_tbl ON temp.ID = request_tbl.ID
?
You no longer have a table you have a result set. Given that, what do
you think is the target of the DELETE?

Syntax of DELETE is

DELETE FROM <table name>
WHERE <predicate>

ASSUMING the temp table is the target of the delete something like
this works:
DELETE FROM temp where temp.ID IN
( select temp.ID FROM temp INNER JOIN request_tbl ON temp.ID =
request_tbl.ID
WHERE temp.name LIKE request_tbl.name ) ;

Have a good day,
Ed


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.