php删除mysql整行_PHP从MySQL数据库删除链接行

bd96500e110b49cbb3cd949968f18be7.png

I need to delete some data from mysql. I know a bit of php but get really lost with mysql and really don't want to mess this up... I did make a .sql backup but I need to get this right. That's why i'm posting the question here. I know I will get some crap for not trying myself and posting my code here but to be hosnest.. this is as far as I got before I got stuck:

$con = mysql_connect("localhost","USERNAME","PASSWORD");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

mysql_select_db("DATABASE", $con);

$result = mysql_query("SELECT * FROM subscriber");

while($row = mysql_fetch_array($result))

{

echo $row['mail'] . " " . $row['snid'];

echo "
";

}

mysql_close($con);

?>

What i'm really trying to do is this:

Locate all rows where status = 0 the in the table called subscription and get the field snid (which is an integer)

Then go to the table called subscriber and delete the row with the matching snid (also a field in this tables row)

Then go back to subscription and delete the original matched row

Does this make sence?.... I've done my own head in just trying to explain it :(

解决方案

To do what you've asked, you only need 1 query:

delete subscriber, subscription from subscriber,subscription where subscription.status = 0 and subscription.snid=subscriber.snid;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值