qq1027507634 2015-03-20 03:05 采纳率: 0%
浏览 957

MySql查询的问题,关于库存量的查询操作

CREATE TABLE who_tmp_real_stock2
SELECT SUM( num ) AS real_stock,goods_id AS goods_id_new
FROM who_goods_stock
GROUP BY goods_id_new
ALTER TABLE who_tmp_real_stock2
ADD UNIQUE (goods_id_new)
SELECT a.goods_id as goods_id,cat_id, d.real_stock, a.goods_sn as goods_sn,goods_name,keywords,is_on_sale,is_delete,
is_best,is_new,is_hot,is_promote,shop_price*100 as shop_price,(shop_price*6.3-in_price)*1000 as profit,
last_update,goods_number,goods_material,goods_color,b.goods_sku_value,customer_rate_num,
(c.sale_num*15+c.stock_num*2) as stock_num,pattern_value,a.add_time

from who_goods_desc b,
who_privilegestocknum c,
who_goods a LEFT JOIN
who_tmp_real_stock2 d ON a.goods_id=d.goods_id_new

where a.goods_id=b.goods_id and
a.goods_id=c.goods_id and
a.goods_id>0 and
c.stock_num>0 and
is_on_sale=1 and
is_delete=0 and
is_freeshipping=0 and
a.goods_number>0
select a.*
from who_goods a
where a.goods_id=$id

SELECT a.goods_id AS goods_id, cat_id, a.goods_sn AS goods_sn, goods_name, keywords, is_on_sale, is_delete,
is_best,is_new, is_hot, is_promote, shop_price *100 AS shop_price, last_update, goods_number, goods_material,
goods_color, pattern_value, c.real_stock
FROM who_goods AS a,
who_goods_desc AS b LEFT JOIN who_tmp_real_stock c ON b.goods_id=c.goods_id_new

WHERE a.goods_id = b.goods_id
AND is_on_sale =1 AND
is_delete =0 AND
is_freeshipping =0 AND
a.goods_number >0
想获取库存量大于0的商品信息,不知道这个sql是不是

  • 写回答

1条回答 默认 最新

  • 恒悦sunsite 运维领域新星创作者 2023-08-02 09:50
    关注

    这个问题排列自己有没有看着很别扭呀?可以选择插入代码的方式,或者适当的使用截图。

    评论

报告相同问题?

悬赏问题

  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题