gpt4 book ai didi

mysql - Condition with join 类似于 where condition after join

转载 作者:行者123 更新时间:2023-11-28 23:13:22 29 4
gpt4 key购买 nike

是不是类似于has and condition with join和where condition after join?

例如

对于以下两个查询,它会给我相同的结果吗

1) SELECT COUNT(*)
FROM language_message_mapping lm
LEFT JOIN user_profiles up ON lm.user_profile_id_fk=user_profile_id_pk
AND lm.user_profile_id_fk IS NOT NULL

2) SELECT COUNT(*)
FROM language_message_mapping lm
LEFT JOIN user_profiles up ON lm.user_profile_id_fk=user_profile_id_pk
where lm.user_profile_id_fk IS NOT NULL

我想更新从上面的查询中得到的行请告诉我下面的更新查询是否正确

UPDATE language_message_mapping lm 
LEFT JOIN user_profiles up ON lm.user_profile_id_fk=user_profile_id_pk
SET lm.user_account_id_fk=up.user_account_id_fk
AND lm.user_profile_id_fk IS NOT NULL;

最佳答案

不,这对于 left join 是不一样的(不过对于 inner join 是一样的)。

第一个查询从第一个表中获取所有记录,并根据您在JOIN ON 子句中的条件从第二个表中添加数据。

第二个查询获取第一个表的所有记录 - 仅获取与 where 子句匹配的数据。

关于mysql - Condition with join 类似于 where condition after join,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44969945/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com