gpt4 book ai didi

php - 在这种情况下如何使用 join

转载 作者:行者123 更新时间:2023-11-30 01:01:19 26 4
gpt4 key购买 nike

我有两个表:

表 pin_info:

id | member_id | look_week | look_name            | is_pinned | date 

1 | 1 | 3 | the improviser | yes | 2013-11-19 21:57:04
2 | 1 | 2 | destined for stardom | yes | 2013-11-19 21:56:00
3 | 1 | 1 | fashinably corporate | no | 2013-11-19 21:54:00

表arrow_ rating:

id | member_id | look_week | look_name            | rating |

1 | 1 | 3 | the improviser | 3 |
2 | 1 | 2 | destined for stardom | 4 |
3 | 2 | 1 | fashinably corporate | 5 |

我想要is_pinned(来自pin_info)和评级(来自评级)。我将拥有参数member_id和look_week。 (分别假设1和2)

我做了什么:

SELECT p_i.is_pinned,a_r.rating 
FROM pin_info p_i,arrow_rating a_r
WHERE p_i.look_week=a_r.look_week AND p_i.member_id='1'

我确信这不是正确的方法。有什么帮助吗?

最佳答案

试试这个:

SELECT pin_info.is_pinned, arrow_rating
FROM pin_info INNER JOIN arrow_rating
ON pin_info.look_week = arrow_rating.look_week
WHERE pin_info.id = '1';

关于php - 在这种情况下如何使用 join,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20106526/

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