gpt4 book ai didi

mysql - 在加入 MySQL 时从主表中选择特定数据

转载 作者:太空宇宙 更新时间:2023-11-03 11:30:16 29 4
gpt4 key购买 nike

enter image description here我有两个表。表一是包含一些产品名称的主表,表二保存分配给特定用户的产品。然后我需要从主表(表 1)中获取产品列表,该表未在用户下添加在表 2 中。上图显示了表结构。

所以当我选择用户 11 时,它不应该是 product_name C.我该如何为此编写 MySQL 查询。

最佳答案

你可以试试这个查询

SELECT table1.product_name FROM `table1`
INNER JOIN table2 on table2.p_id = table1.p_id
WHERE table2.user_id = 11

关于mysql - 在加入 MySQL 时从主表中选择特定数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50653366/

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