Hi,
I have two tables.
Table1:
MySymbol, BloombergSymbol
A, A_Bloomberg
B, B_Bloomberg
Table2:
MySymbol, Open, High, Low, Close
A,...
A,...
B,...
B,...
I want to perform one task--Delete all the records in table2 whose MySymbol matches one given BloombergSymbol in table1.
3x.which dbms is this?|||Try this query:
Delete Table2.* from Table1 LEFT JOIN Table2 ON Table1.MySymbol = Table2.MySymbol|||Alternate syntax :
DELETE FROM table2 WHERE MySymbol IN (SELECT MySymbol FROM table1)
n.b. I have based this on MySQL syntax which may or may not work in your DB.|||sql server
which dbms is this?|||this one works.
thank you guys.
Alternate syntax :
DELETE FROM table2 WHERE MySymbol IN (SELECT MySymbol FROM table1)
n.b. I have based this on MySQL syntax which may or may not work in your DB.|||For SQL Server use:
DELETE table2
FROM table2
INNER JOIN table1 ontable2.MySymbol = table1.MySymbol
Friday, March 23, 2012
Help on delete statement
Labels:
a_bloombergb,
b_bloombergtable2mysymbol,
bloombergsymbola,
closea,
database,
delete,
microsoft,
mysql,
oracle,
server,
sql,
statement,
table1mysymbol,
tables
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment