ZBLOG

LEFT JOIN shop s2 ON s1.price < s2.price After it, what would mysql do to set NULL to s2.article

When you use a LEFT JOIN with the condition s1.price < s2.price, it means that for each row in s1, MySQL will try to find all the rows in s2 where the price is lower than the price in s1.

If there is no such row in s2, then all the columns of s2 will be NULL for that particular row of s1. This happens because LEFT JOIN returns all the rows from the left table (s1 in this case) along with any matching rows from the right table (s2).

However, if there is a matching row in s2, then MySQL will set the values of the columns in s2 for that particular row based on the values in the matching row. In this case, s2.article would have a non-NULL value.

So in the context of the query:

SELECT s1.article, s1.dealer, s1.price
FROM shop s1
LEFT JOIN shop s2 ON s1.price < s2.price
WHERE s2.article IS NULL;

the condition s2.article IS NULL is used to filter out the rows where there is a matching row in s2, i.e., where s1 is not the row with the lowest price for that article. By checking if s2.article is NULL, we can determine whether s1 has the minimum price for that article or not.

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=833

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?