首页 文章

语法错误Mysql

提问于
浏览
1

不知道为什么这不起作用 - 有人可以帮忙吗?

update c set c.images = ""
from j17_content c
inner join j17_jreviews_content rc on rc.contentid = c.id 
inner join j17_categories cat on cat.id = c.catid
where cat.path like "cakes%"
and c.created_by in (62,63,99)
and rc.email = 'email'

错误#1064 - 您的SQL语法出错;查看与您的MySQL服务器版本对应的手册,以便在'第2行'中的rc.contentid = c.id附近使用'j17_content c inner join j17_jreviews_content rc'附近使用正确的语法

更新:

现在尝试

UPDATE j17_content c SET c.images=''
inner join j17_jreviews_content rc on rc.contentid = c.id 
inner join j17_categories cat on cat.id = c.catid
where cat.path like 'cakes%'
and c.created_by in (62,63,99)
and rc.email = 'email'

还在

错误#1064 - 您的SQL语法出错;查看与您的MySQL服务器版本对应的手册,以便在第2行的rc.contentid = c.id inner join j17_catego''内部连接j17_jreviews_content rc附近使用正确的语法

4 回答

  • 0

    对不起,这不是你们建议的方式 - 但我得到了一个ID列表,并使用所有ID的in语句中没有连接更新它们

  • 1

    这是你的代码 .

    试试这种方式:

    update j17_content c 
    inner join j17_jreviews_content rc on rc.contentid = c.id  
    inner join j17_categories cat on cat.id = c.catid 
    where cat.path like 'cakes%'
    and c.created_by in (62,63,99) 
    and rc.email = 'email' 
    set c.images = '';
    

    这是一个更新加入

    我有一个重构版本的查询

    update  
    (
        SELECT content_id id
        FROM j17_jreviews_content
        WHERE email = 'email'
    ) rc
    inner join j17_content c USING (id)
    inner join
    (
        SELECT id catid
        FROM j17_categories
        WHERE created_by in (62,63,99)
        AND path like 'cakes%'
    ) cat USING (catid)
    set c.images = '';
    

    您将需要所涉及子查询的索引

    ALTER TABLE j17_categories ADD INDEX created_by_path_id_ndx (created_by,path,id);
    ALTER TABLE j17_jreviews_content ADD INDEX email_content_id_ndx (email,content_id);
    
  • 1

    UPDATE 不接受 FROM .

    语法应为 UPDATE j17_content c SET c.images="" INNER JOIN ...

  • 0

    用单个(')替换双引号(“)

相关问题