|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
help on delete statementHi,
I'm using SQL 2000. I have 2 tables, Invoice and Products. In 'Invoice' table, there are 2 cols: Invoice/invoicedate In Products table, there are 2 cols: Invoice/Productid At the front end 'Access", these two tables are linked using 'invoice' field. But on SQL backend side, I didn't have any relationship between two tables. Now I like to delete some records based on the invoicedate. How can I delete records from both table if the invoice is the same. I hope I explain the question properly, if not, please feel free to ask me. Thanks in advance, Sarah Something like this..
DELETE FROM products WHERE InvoiceNo IN (SELECT InvoiceNo FROM Invoice WHERE InvoiceDate = 'YourDate') DELETE FROM Invoice WHERE InvoiceDate = 'YourDate' - Sha Anand Show quote "S.G." wrote: > Hi, > > I'm using SQL 2000. > > I have 2 tables, Invoice and Products. > In 'Invoice' table, there are 2 cols: Invoice/invoicedate > In Products table, there are 2 cols: Invoice/Productid > > At the front end 'Access", these two tables are linked using 'invoice' > field. But on SQL backend side, I didn't have any relationship between two > tables. > Now I like to delete some records based on the invoicedate. How can I delete > records from both table if the invoice is the same. > > I hope I explain the question properly, if not, please feel free to ask me. > > Thanks in advance, > Sarah > > > Hi Sha, Thanks so much.Sarah
Show quote "Sha Anand" <ShaAn***@discussions.microsoft.com> wrote in message news:C3956268-9339-45C7-BF21-12AE0E41DCA4@microsoft.com... > Something like this.. > > DELETE FROM products > WHERE InvoiceNo IN (SELECT InvoiceNo FROM Invoice WHERE InvoiceDate = > 'YourDate') > DELETE FROM Invoice WHERE InvoiceDate = 'YourDate' > > - Sha Anand > > "S.G." wrote: > >> Hi, >> >> I'm using SQL 2000. >> >> I have 2 tables, Invoice and Products. >> In 'Invoice' table, there are 2 cols: Invoice/invoicedate >> In Products table, there are 2 cols: Invoice/Productid >> >> At the front end 'Access", these two tables are linked using 'invoice' >> field. But on SQL backend side, I didn't have any relationship between >> two >> tables. >> Now I like to delete some records based on the invoicedate. How can I >> delete >> records from both table if the invoice is the same. >> >> I hope I explain the question properly, if not, please feel free to ask >> me. >> >> Thanks in advance, >> Sarah >> >> >> |
|||||||||||||||||||||||