doucaigai7176 2015-03-24 20:29
浏览 35
已采纳

在mysql查询后从php中的变量中删除行

Hi Friends , I need a small help to figure out how to delete the rows from table "Item" if "Item code" is there in table "Order_summery" for a particular subscriber.

table ## ITEM :

Item code   name    waight  cost    colour
8956        aaa      10     100     red 
2514        cccc     20     110     red 
7945        dddd     30     140     white
3156        eeee     40     90      black

table ### Order_summery:

oder    customer_iD     Item code   Bonus   cost
11265        45           7945       10     126

Code:

$sql= "SELECT * FROM ITEM";
$resultser=mysql_query($sql) or mysql_error(); 

$sql2= "SELECT * FROM Order_summery where customer_iD = 45 ";
$result=mysql_query($sql2) or mysql_error(); 

now how to delete the row number 4 of variable $sql as the same Item code is there in table "Order_summery"

  • 写回答

1条回答 默认 最新

  • doudiewen9435 2015-03-24 20:39
    关注

    If you want to delete records from table item and keep records in order_summary table , then try this

     DELETE FROM item WHERE item_code IN (SELECT item_code FROM Order_Summary);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度