这里是我的查询:如何在UPDATE语句中使用JOIN?
UPDATE reputations SET
type = new.type,
score = new.score,
qora = NOT (new.post_id = (SELECT t1.id
FROM qanda t1
WHERE (EXISTS (SELECT 1
FROM qanda t2
WHERE ID = new.post_id
AND t1.ID = t2.related)
OR t1.id = new.post_id)
AND Type = 0)),
question_id = (SELECT t1.id
FROM qanda t1
WHERE (EXISTS (SELECT 1
FROM qanda t2
WHERE ID = new.post_id
AND t1.ID = t2.related)
OR t1.id = new.post_id)
AND Type = 0),
post_id = new.post_id,
table_code = new.table_code,
comment_id = new.comment_id,
owner_id = new.author_id,
date_time = UNIX_TIMESTAMP()
WHERE events_table_id = old.id;
所有我想要做的是去除那些子查询的一个,因为两者是相同的。我怎样才能做到这一点?
我不认为你的括号平衡。 –
@GordonLinoff真的......我又增加了一个。 –