[英]Select row from one table where multiple rows in another table have determined values
[英]Select rows from a table where row in another table with multiple condition
我有3個表App , concept和app_to_concept
應用表
app_id | app_name
=================
1 | foo
2 | bar
3 | foobar
4 | barfoo
概念表
concept_id | concept_name
=========================
1 | english
2 | math
3 | science
4 | Fun
app_to_concept表
concept_id | app_id
=========================
1 | 1
2 | 1
3 | 2
4 | 3
2 | 2
2 | 4
我想獲取所有具有概念english
和math
app list
(例如)
我怎樣才能做到這一點?
讓我更具體一點
我有一些具有概念價值的復選框。 當我選中復選框時,它將返回與選中的概念相關的應用程序詳細信息。 現在我的情況是用例子解釋
如果我選中了english
和math
概念復選框,它將顯示具有概念english
或 math
應用程序詳細信息,同樣的science
和fun
。 現在,當我檢查english
, math
和science
結果應顯示具有english
或 math
和 science
應用程序細節。 意味着app有
english
和science
math
和science
基本的JOIN
會做。
select a.app_name
from app_to_concept ac
INNER JOIN app_table a ON ac.app_id = a.app_id
INNER JOIN concept_table c ON ac.concept_id = c.concept_id
WHERE c.concept_name IN ('english', 'math');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.