Mysql 加入和过滤
Mysql join & filter
如何在下面的查询中添加另一个 table 作为条件
我有以下查询
SELECT Group_concat(cl.name) AS category FROM sco_category_product cp
LEFT JOIN sco_category_lang cl ON (cp.id_category= cl.id_category) WHERE id_product = 3 AND cl.id_shop = 1
给我输出
category
Juniors,Juniors size chart
我有一个 table "sco_category
",其中有 "id_category" & "active"
列。
我想创建一个与我编写的上述查询合并的查询,并仅提供活动 "id_category"
的输出。
例如,“Juniors
”是“id_category
”的名称,如果不活动,即(“active
”列中有 0
值。)然后将其从数据中排除。
请分享您对此的看法。
如果我没听错,那又是一个加入:
select group_concat(cl.name) as category
from sco_category_product cp
inner join sco_category_lang cl on cp.id_category= cl.id_category
inner join sco_category c on c.id_category = cl.id_category
where cp.id_product = 3 and cl.id_shop = 1 and c.active = 1
如何在下面的查询中添加另一个 table 作为条件
我有以下查询
SELECT Group_concat(cl.name) AS category FROM sco_category_product cp
LEFT JOIN sco_category_lang cl ON (cp.id_category= cl.id_category) WHERE id_product = 3 AND cl.id_shop = 1
给我输出
category
Juniors,Juniors size chart
我有一个 table "sco_category
",其中有 "id_category" & "active"
列。
我想创建一个与我编写的上述查询合并的查询,并仅提供活动 "id_category"
的输出。
例如,“Juniors
”是“id_category
”的名称,如果不活动,即(“active
”列中有 0
值。)然后将其从数据中排除。
请分享您对此的看法。
如果我没听错,那又是一个加入:
select group_concat(cl.name) as category
from sco_category_product cp
inner join sco_category_lang cl on cp.id_category= cl.id_category
inner join sco_category c on c.id_category = cl.id_category
where cp.id_product = 3 and cl.id_shop = 1 and c.active = 1