mysql查询中的错误 - 内部连接在哪里

时间:2021-10-08 00:10:01

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 ?

我不能在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)

2 个解决方案

#1


1  

Express it as a simple IN:

将其表达为简单的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

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

#2


1  

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

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

It must be something like this:

必须是这样的:

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

UPDATE oferta_has_tags一个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:

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

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

更新oferta_has_tags一个SET fraccao =“1/7”WHERE id IN(SELECT id FROM yourtable WHERE something = somevalue)

Hope it helps...

希望能帮助到你...

#1


1  

Express it as a simple IN:

将其表达为简单的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

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

#2


1  

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

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

It must be something like this:

必须是这样的:

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

UPDATE oferta_has_tags一个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:

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

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

更新oferta_has_tags一个SET fraccao =“1/7”WHERE id IN(SELECT id FROM yourtable WHERE something = somevalue)

Hope it helps...

希望能帮助到你...