产品表:products
产品订单表:orders_products
产品:products 表结构products_id products_title 1 时尚长裙2 时尚短裙产品订单:orders_products表结构orders_id products_id1 12 13 2需求:根据关键字(时尚)查询,并按产品热卖程度排序(统计订单表中产品进行排序)。请问SQL要怎样写呢,亲们。
产品订单表:orders_products
产品:products 表结构products_id products_title 1 时尚长裙2 时尚短裙产品订单:orders_products表结构orders_id products_id1 12 13 2需求:根据关键字(时尚)查询,并按产品热卖程度排序(统计订单表中产品进行排序)。请问SQL要怎样写呢,亲们。
from products A,orders_products B
where A.products_id = B.products_id
group by B.products_id
order by num desc
products_id products_title num
1 时尚长裙 2
2 时尚短裙 1
from products A inner join orders_products B
on A.products_id = B.products_id where instr(a.products_title,'时尚')>0
group by a.products_id,a.products_title
order by num desc
from products p,orders_products o
where p.products_id=o.products_id
group by p.products_id ,p.products_title
order by 3 desc