SELECT iidonhand pdattr_name10 SUBSTRING_INDEX ROUND iidonhand pdattr_name10 3 -1 FROM inventory_item_detail iid LEFT JOIN product_detail pd ON iidproduct_detail_id = pdproduct_detail_id WHERE pdpro
The given SQL query retrieves the onhand quantity, attr_name10, and the decimal part of the onhand quantity for a specific product detail.
Here is the modified query:
SELECT
iid.onhand,
pd.attr_name10,
SUBSTRING_INDEX(ROUND(iid.onhand, pd.attr_name10, 3), '.', -1)
FROM
inventory_item_detail iid
LEFT JOIN product_detail pd ON iid.product_detail_id = pd.product_detail_id
WHERE
pd.product_detail_id = 'P230804193-3-20007489-1'
Explanation of the query:
- The
SELECTstatement is used to select the desired columns from the tables. iid.onhandretrieves the onhand quantity from theinventory_item_detailtable.pd.attr_name10retrieves the attr_name10 from theproduct_detailtable.SUBSTRING_INDEX(ROUND(iid.onhand, pd.attr_name10, 3), '.', -1)retrieves the decimal part of the onhand quantity by rounding it to 3 decimal places and then using the substring function to get the part after the decimal point.- The
FROMclause specifies the tables used in the query. - The
LEFT JOINkeyword is used to join theinventory_item_detailandproduct_detailtables based on theproduct_detail_idcolumn. - The
WHEREclause is used to filter the rows based on the conditionpd.product_detail_id = 'P230804193-3-20007489-1'
原文地址: http://www.cveoy.top/t/topic/iOcw 著作权归作者所有。请勿转载和采集!