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 SELECT statement is used to select the desired columns from the tables.
  • iid.onhand retrieves the onhand quantity from the inventory_item_detail table.
  • pd.attr_name10 retrieves the attr_name10 from the product_detail table.
  • 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 FROM clause specifies the tables used in the query.
  • The LEFT JOIN keyword is used to join the inventory_item_detail and product_detail tables based on the product_detail_id column.
  • The WHERE clause is used to filter the rows based on the condition pd.product_detail_id = 'P230804193-3-20007489-1'
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

原文地址: http://www.cveoy.top/t/topic/iOcw 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录