[英]WooCommerce-mysql - get list of products in a category
我想檢索子類別中的所有產品。 這是我的代碼:
SELECT * from `wp_term_relationships` where term_taxonomy_id=$subcatId and
object_id in(select ID from `wp_posts` where `post_type`='product' and post_status='publish' and ID=wp_term_relationships.object_id)
問題是,此代碼返回大約20種產品,但是當我轉到網站中的該類別時,它返回大約40種產品。
你可以幫幫我嗎 ? 我需要一個代碼來返回類別中的產品列表。
SELECT * from `wp_term_relationships` where term_taxonomy_id=$subcatId and object_id in(select ID from `wp_posts` where `post_type`='product' and post_status='publish' and ID=wp_term_relationships.object_id) LIMIT 0,15000000
在mysql查詢中使用Limit關鍵字。
限制接受開始和結束值。
如果您給出Limit 5
,它將僅顯示前5條記錄。 如果給出Limit 5,10
,它將顯示5-10之間的記錄。 如果您給限制0,big number(例如Limit 0,100000000
),它將顯示所有記錄,直到100000000。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.