我在MySQL中遇到了问题。这是我的代码:
UPDATE ad_copy, (
SELECT CONCAT_WS(" - ", ad_copy.title, stitle.ttitle) AS `p`
from ad_copy, stitle
where ad_copy.category = stitle.subcat
ORDER BY RAND()) `p`
set `title` = `p`
where ad_copy.category = stitle.subcat
我无法理解问题所在。在此先感谢您的帮助
答案 0 :(得分:0)
尝试使用加入更新,无法识别子查询(SELECT CONCAT_WS ..) as p
的自定义列
UPDATE
ad_copy a
JOIN stitle s ON (a.category = s.subcat)
SET a.`title` = CONCAT_WS( " - ",a.title,s.ttitle)
修改强>
UPDATE
ad_copy a
JOIN stitle s ON (a.category = s.subcat)
SET a.`title` = CONCAT_WS( " - ",a.title, (SELECT ttitle FROM stitle WHERE subcat =a.category ORDER BY RAND() LIMIT 1 ))