大佬教程收集整理的这篇文章主要介绍了php-按产品过滤订单,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我是@L_801_0@开发的新手.我不太擅长@L_801_0@ join :(.
请帮助我编写一个SQL查询,以从下表中提取产品“家用便携式激光脱毛器”的以下文件.
所需文件:
orders.id,orders.order_price,orders.purchase_date,customers.email,product_orders.qty,products.name
表1:订单
id customer_id order_price purchase_date
1 1 0.20 12/6/2011
2 2 0.20 12/6/2011
3 1 0.20 12/6/2011
4 1 0.20 12/6/2011
5 1 0.20 12/7/2011
6 3 199.00 12/7/2011
7 4 199.00 12/7/2011
8 5 199.00 12/7/2011
9 6 199.00 12/7/2011
10 7 199.00 12/7/2011
表2:客户
id email name
1 aa@dealboard.com.au aa
2 bb@dealboard.com.au bb
3 cc@live.com.au cc
4 dd@acgglobal.com dd
5 ee.heinrich@det.nsw.edu.au ee
6 ff@optusnet.com.au ff
7 ssy@hotmail.com ss
表3:产品
id name
1 A Home Portable Laser Hair Remover
2 Ipad
3 android
4 Asus
5 s
6 10 inch Android
7 A Fabric Steamer Cleaner
8 A Magnetic Fly Screen Door
9 pillopw
10 LCD
表4:product_orders
id orders_id product_id qty
1 1 1 1
2 2 1 1
3 3 1 1
4 4 1 1
5 5 2 1
6 6 1 1
7 7 1 1
8 8 1 1
9 9 1 1
10 10 1 1
我想提取产品ID 1的所有订单或按产品过滤订单
请帮我
解决方法:
听起来像您想加入所有表:
SELEct orders.id, orders.order_price, orders.purchase_date, customers.email,
product_orders.qty, products.name from orders, customers, product_orders,
products where
orders.customer_id = customers.id and
product_orders.order_id = orders.id and
products.id = product_orders.product_id and
products.id = 1
以上是大佬教程为你收集整理的php-按产品过滤订单全部内容,希望文章能够帮你解决php-按产品过滤订单所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。