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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleteing Data from two tables in one Query 2

Status
Not open for further replies.

wilcoHead

Programmer
Feb 2, 2005
85
I am sure this is simple but I am doiung something wrong here.

I am trying to delete 1 record that has info stored in two tables.

Here is the Query:

<CFQUERY NAME="DELETE_form" DATASOURCE="#Local_users_DB#">
DELETE FROM Partner_access_tbl, Log_Partner_Access
WHERE Partner_accessID = #URL.id# AND frn_partner_id = #URL.id#
</CFQUERY>

So, the unique number in both tables from the one record resides in both Partner_accessID and frn_partner_id.

How do I make this work?

Thanks,

Thanks for your input;
WilcoHEAD
 
There is probably a better way to do it but I would use two separate deletes:

<CFQUERY NAME="DELETE_form" DATASOURCE="#Local_users_DB#">
DELETE FROM Partner_access_tbl
WHERE Partner_accessID = #URL.id#
</CFQUERY>

<CFQUERY NAME="DELETE_form" DATASOURCE="#Local_users_DB#">
DELETE FROM Log_Partner_Access
WHERE frn_partner_id = #URL.id#
</CFQUERY>

If you could do it in one step it would be more efficient.

Cheers,

Bluetone
 
It will not allow me to do it one at a time because the id belongs to another table so I get an error.

Thanks for your input;
WilcoHEAD
 
Delete the child record before you delete the parrent record.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Thanks to both of you.

It worked!

Thanks for your input;
WilcoHEAD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top