deleting multiple rows from multiple table prob??

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

deleting multiple rows from multiple table prob??

Post by PHPycho »

--------------------------------------------------------------------------------

Now i am going to tell in detail about my Problem...
I had two tables 'frensrequest' and 'frensnetwork' with the following fields and values(assumed).

frensnetwork
|fn_id|user_id|fren_id|block_status|
|1 |1 |2 | 0 |
|2 |2 |1 | 0 |

frensrequest
|req_id|req_to|req_from|pending_status|
|1 |2 |1 | 1 |

I had made a Edit friends Section where users can edit friends in their network(like hi5) .
Let us suppose i am the user with user_id=1 .i want to delete friend with fren_id=2...on successful delete operation it should delete two rows from 'frensnetwork' with user_id=1 or 2 and fren_id=2 or 1 ie two rows with fn_id=1 and 2...
at the same time it should delete one row from the 'frenrequest' with req_to=2 and pending_status=1....
How to peform the single query to delete two rows from 'frensnetwork' and one from 'frenrequest' ...
I hope my problem is clear to you.....
I am waiting eagerously for the reply from u.......
again i want to give thanks in advance
Post Reply