gpt4 book ai didi

php - 如何根据另一个表中的公共(public) id 值选择一个表中的记录?

转载 作者:行者123 更新时间:2023-11-29 08:28:45 25 4
gpt4 key购买 nike

我试图根据 ca_list_item_labels 和 ca_list_items 之间的公共(public)字段 (item_id) 返回表 ca_list_item_labels 中的“描述”字段,其中 ca_list_items 中的 list_id = 41。

我能管理的最接近的事情是使用子查询...我对编写 mySQL 查询相当陌生。

我尝试了以下两个查询,但没有成功:

    SELECT description FROM ca_list_item_labels UNION SELECT * FROM ca_list_items WHERE 'list_id' = 41;

SELECT description FROM ca_list_item_labels WHERE (SELECT item_id FROM ca_list_items WHERE 'list_id' = 41);

最佳答案

您应该能够通过简单的连接来做到这一点。像这样的东西应该有效:

   SELECT decsription 
FROM ca_list_item_labels JOIN ca_list_items USING (item_id)
WHERE list_id = 41

关于php - 如何根据另一个表中的公共(public) id 值选择一个表中的记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17243113/

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