I have two tables ( a & b ) Both are linked by a ledgerref field. table what
would be the quickest and easiest way to delete records from both when
a.textStatus = 1the only way.. the usual way
delete from b from a,b
where b.ledgerref = a.ledgerref
and a.textStatus = 1
delete from a where textStatus = 1
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/|||and of course enclose it with a transaction :)
--
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/|||If the two tables are PK-FK linked, you could use CASCADE DELETE.
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"Peter Newman" <PeterNewman@.discussions.microsoft.com> wrote in message
news:1523DBF8-B27F-4351-970C-AF93A4316705@.microsoft.com...
>I have two tables ( a & b ) Both are linked by a ledgerref field. table
>what
> would be the quickest and easiest way to delete records from both when
> a.textStatus = 1|||Or getting it out of dialect, and correcting the "textStatus" data
element name (test and status are both suffixes to an attribute in
ISO-11179). I will not comment on the practice of using flags in SQL
to mimic an assembly language programming, or redundant tables to mimic
scratch tapes.
DELETE FROM Beta
WHERE EXISTS
(SELECT *
FROM Alpha
WHERE Beta.ledger_ref = Alpha.ledger_ref
AND Alpha.foobar_status = 1);
DRI action would be better. The best solution would be a proper
relational design.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment