Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

Delete from 2 tables, working in vb6 and mysql

hi can anyone help me please ???? i have two tables

1. invoice
2. visainfo

and for one invoice record there are many visainfo records so i need a query to delete an invoice record and all the related records from the visainfo table..

delete from invoice,visainfo
where visainfo.invoiceno=invoice.invoiceno
and invoiceno='2'

where invoiceno is the key field in the invoice table
0
parmoon
Asked:
parmoon
  • 2
1 Solution
 
BatalfCommented:
You need two queries:

delete from invoice where invoiceno='2';
delete from visainfo where invoiceno='2';


0
 
parmoonAuthor Commented:
i know but i want to do it in one go or in one statement.............
0
 
snoyes_jwCommented:
As of MySQL 4.0, you can do
DELETE invoice, visainfo FROM invoice, visainfo WHERE visainfo.invoiceno = 2 AND visainfo.invoiceno = invoice.invoiceno;
0
 
parmoonAuthor Commented:
thanks thats what i wanted
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now