mysql 查询错误 - where 内的内部联接

发布于 2024-12-12 05:24:08 字数 420 浏览 0 评论 0原文

我收到此错误:

for the right syntax to use near 'INNER JOIN oferta B ON A.oferta_id_oferta = B.id_oferta AND B.oferta = "design' at line 4

我无法在 where 子句中进行内部联接?或者此查询存在其他问题?

UPDATE `oferta_has_tags` A
    SET fraccao = "1/7"
    WHERE (
    INNER JOIN oferta B
    ON A.oferta_id_oferta = B.id_oferta
    AND B.oferta = "designer"
    AND B.estado = 0)

i got this error:

for the right syntax to use near 'INNER JOIN oferta B ON A.oferta_id_oferta = B.id_oferta AND B.oferta = "design' at line 4

i can't make a inner join inside a where clause ? or exists other problem with this query ?

UPDATE `oferta_has_tags` A
    SET fraccao = "1/7"
    WHERE (
    INNER JOIN oferta B
    ON A.oferta_id_oferta = B.id_oferta
    AND B.oferta = "designer"
    AND B.estado = 0)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初熏 2024-12-19 05:24:08

将其表达为简单的 IN

UPDATE oferta_has_tags
SET fraccao = '1/7'
WHERE oferta_id_oferta IN (
    SELECT id_oferta 
    FROM oferta
    WHERE oferta = 'designer'
    AND estado = 0)

此外,将双引号 (") 更改为单引号 (') - 使用双引号会导致错误

Express it as a simple IN:

UPDATE oferta_has_tags
SET fraccao = '1/7'
WHERE oferta_id_oferta IN (
    SELECT id_oferta 
    FROM oferta
    WHERE oferta = 'designer'
    AND estado = 0)

Also, changed double quotes (") to single quotes (') - using double quotes will cause an error

榆西 2024-12-19 05:24:08

查询错误。它必须有 SELECT 和 FROM 子句:

它必须是这样的:

更新oferta_has_tags A
设置 fraccao =“1/7”
WHERE id = ( SELECT id FROM yourtable WHERE Something = somevalue )

确保子查询应恰好返回 1 个值。如果要使用上述查询更新多条记录,请将“=”替换为“IN”。像这样:

更新oferta_has_tags A
设置 fraccao =“1/7”
WHERE id IN ( SELECT id FROM yourtable WHERE some = somevalue )

希望它有帮助...

The query is wrong. It must have SELECT and FROM clauses:

It must be something like this:

UPDATE oferta_has_tags A
SET fraccao = "1/7"
WHERE id = ( SELECT id FROM yourtable WHERE something = somevalue )

Make sure that the subquery should return exactly 1 value. If you want to update multiple records using above query, replace "=" with "IN". Like this:

UPDATE oferta_has_tags A
SET fraccao = "1/7"
WHERE id IN ( SELECT id FROM yourtable WHERE something = somevalue )

Hope it helps...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文