Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting from multple tables

Status
Not open for further replies.

Deleted

Technical User
Jul 17, 2003
470
US
I am try to delete from several tables (10++).

This is what I got so far.
Code:
DELETE FROM address, dgraph, folders, filter, msgs_remote, msgtrack, pop_accounts, sigs,  User, Post, PostNew, EditLog, Online, UserGroup USING address, dgraph, folders, filter, msgs_remote, msgtrack, pop_accounts, sigs, User, Post, PostNew, EditLog, Online, UserGroup WHERE address.address_userid = dgraph.dgraph_userid AND folders.folders_userid = filter.filter_userid AND msgs_remote.msgs_remote_userid = msgtrack.msgtrack_userid AND pop_accounts.pop_accounts_userid = sigs.sigs_userid AND Post.user_id_fk = PostNew.user_id_fk AND EditLog.user_id_fk = Online.user_id_fk AND UserGroup.user_id_fk = User.user_id AND User.user_id = X

This works without errors but fails to delete when any of the tables referenced contain no data.

Any way around this?

My goal is to delete from each table where the *_userid = *_userid AND *_user_id = X..

M. Brooks
X Concepts LLC
 
It's to be expected that when one table in the chain fails to have any records, no records are deleted. You're using inner joins to join your tables.

You might try using left joins instead, but I'd just recommend performing multiple simpler queries.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top