Substring (num) ASreal_stock, comment 'who _ tmp_real_stock2 'ADDUNIQUE ('goods _ id_new') SELECTa. goods_idasgoods_id, cat_id, d. real_stock,... mysqlselect
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 TABLEwho_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 .*
From who_goods
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,
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
If you want to obtain the product information whose inventory is greater than 0, do you know if this SQL statement is correct?