dsbowmvth16379079 2016-03-29 12:20
浏览 102
已采纳

更新时子查询返回多行

I am writing one simple SQL query to update my table .

here is my code

$qry = mysql_query("update product set cat_tree =(select cat_name from cat_details where product.category = cat_details.cat_id )");

When ever i tried to run this code its giving error message

#1242 - Sub query returns more than 1 row

What is the problem ? I tried with so many solutions like "IN" "ANY" . But all examples are for insert query only.

Thanks in advance

  • 写回答

3条回答 默认 最新

  • dr6673999 2016-03-29 12:47
    关注

    You should try LIMIT like this...

    $qry = mysql_query("update product set cat_tree =(select cat_name from cat_details where product.category = cat_details.cat_id LIMIT 1)");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 使用yolov5-7.0目标检测报错
  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备