簡體   English   中英

從一個表中選擇行,其中另一個表中的行具有多個條件

[英]Select rows from a table where row in another table with multiple condition

我有3個表Appconceptapp_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

我想獲取所有具有概念englishmath app list (例如)

我怎樣才能做到這一點?

編輯

讓我更具體一點

我有一些具有概念價值的復選框。 當我選中復選框時,它將返回與選中的概念相關的應用程序詳細信息。 現在我的情況是用例子解釋

如果我選中了englishmath概念復選框,它將顯示具有概念english math應用程序詳細信息,同樣的sciencefun 現在,當我檢查englishmathscience結果應顯示具有english math science應用程序細節。 意味着app有

englishscience

mathscience

基本的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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM