?
Solved

Delete from 2 tables, working in vb6 and mysql

Posted on 2005-02-28
4
Medium Priority
?
340 Views
Last Modified: 2008-02-01
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
Comment
Question by:parmoon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 32

Expert Comment

by:Batalf
ID: 13418882
You need two queries:

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


0
 

Author Comment

by:parmoon
ID: 13418912
i know but i want to do it in one go or in one statement.............
0
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 200 total points
ID: 13419881
As of MySQL 4.0, you can do
DELETE invoice, visainfo FROM invoice, visainfo WHERE visainfo.invoiceno = 2 AND visainfo.invoiceno = invoice.invoiceno;
0
 

Author Comment

by:parmoon
ID: 13419910
thanks thats what i wanted
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question