gpt4 book ai didi

php - 附加 where 子句

转载 作者:行者123 更新时间:2023-11-29 14:05:28 28 4
gpt4 key购买 nike

我有以下代码来返回我想要的字符串

$sql = "
SELECT `description`
FROM `auctions`
WHERE `description` REGEXP '[0-9]{10}'
";

但是我需要运行类似这样的更新查询

UPDATE `url` 
FROM `auctions_media`
WHERE `url` = "$sql" AND `auction_id` = SomeNumber

如何匹配表格,以便 auctions 表的 auction_idauctions_media 表中的 auction_id 相匹配??

我希望代码遍历所有行,从描述中返回字符串,然后将其用于更新查询

最佳答案

也不完全确定你在追求什么,但也许是这样的:

UPDATE auctions_media JOIN auctions USING (auction_id)
SET auctions_media.url = auctions.description
WHERE auctions.description REGEXP '[0-9]{10}'

或者这个:

UPDATE auctions
JOIN auctions_media
ON auctions_media.auction_id = auctions.auction_id
AND auctions_media.url = auctions.description
SET ...
WHERE auctions.description REGEXP '[0-9]{10}'

关于php - 附加 where 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14422920/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com