Link to home
Start Free TrialLog in
Avatar of robrodp
robrodpFlag for Mexico

asked on

delete records form a mysql table

In ms sql

delete table1 from table2 where table1.field=table2.field

Works ok

How can I do the same for 2 tables in mysql

Any ideas
Avatar of PortletPaul
PortletPaul
Flag of Australia image

are you sure this works?  delete table1 from table2 where table1.field=table2.field it looks invalid to me.

Perhaps you could paste in the actual sql being used?

also, what is the extra query supposed to do, is it still just deleting rows in table1?
Avatar of robrodp

ASKER

delete b2x1 from borrarproc where b2x1.email=borrarproc.email

Just deleted 1333 see attached screenshot. And yes it is just deleting rows in table 1
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
in your later example, apply this:

delete b2x1.* from b2x1
inner join borrarproc
on b2x1.email=borrarproc.email

Open in new window


if you want to delete records from table b2x1 which matched condition with table: borrarproc
May be you need to write something like this
DELETE t1,t2,t3 FROM table1 as t1
JOIN table2 as t2 ON t2.ID = t1.ID
JOIN table3 as t3 ON t3.ID = t1.ID

Open in new window

Avatar of robrodp

ASKER

Worked like a charm

Thx