Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 用于检查WooCommerce中产品类型的SQL查询_Mysql_Wordpress_Woocommerce - Fatal编程技术网

Mysql 用于检查WooCommerce中产品类型的SQL查询

Mysql 用于检查WooCommerce中产品类型的SQL查询,mysql,wordpress,woocommerce,Mysql,Wordpress,Woocommerce,我想通过MySQL通过简单或可变产品过滤WooCommerce中的产品;但我无法找到WooCommerce如何存储数据并在数据库中区分它们 我想要一个MySQL查询,列出所有简单和可变的产品;我不需要任何PHP代码 比如: SELECT * FROM wp_posts WHERE post_type = 'product' AND product_type = 'simple'; MySQL查询以列出所有简单产品: SELECT posts.ID, posts.post_tit

我想通过MySQL通过简单或可变产品过滤WooCommerce中的产品;但我无法找到WooCommerce如何存储数据并在数据库中区分它们

我想要一个MySQL查询,列出所有简单和可变的产品;我不需要任何PHP代码

比如:

SELECT * FROM wp_posts WHERE post_type = 'product' AND product_type = 'simple';

MySQL查询以列出所有简单产品

SELECT
    posts.ID,
    posts.post_title,
    posts.post_author,
    posts.post_date,
    posts.post_date_gmt,
    posts.post_content,
    posts.post_excerpt,
    posts.post_status,
    posts.comment_status,
    posts.ping_status,
    posts.post_password,
    posts.post_name,
    posts.to_ping,
    posts.pinged,
    posts.post_modified,
    posts.post_modified_gmt,
    posts.post_content_filtered,
    posts.post_parent,
    posts.guid,
    posts.menu_order,
    posts.post_type,
    posts.post_mime_type,
    posts.comment_count
FROM
    wp_posts AS posts
INNER JOIN wp_term_relationships AS term_relationships ON posts.ID = term_relationships.object_id
INNER JOIN wp_term_taxonomy AS term_taxonomy ON term_relationships.term_taxonomy_id = term_taxonomy.term_taxonomy_id
INNER JOIN wp_terms AS terms ON term_taxonomy.term_id = terms.term_id
WHERE
    term_taxonomy.taxonomy = 'product_type'
AND terms.slug = 'simple'
AND posts.post_type = 'product';
只需将
中的
simple
和terms.slug='simple'
行替换为
变量
,即可获得所有变量产品

我已经测试了这个SQL查询,它显示了正确的结果


希望这有帮助

这正是我想要的。非常感谢。@user1375291:如果这对您有帮助,请接受我的回答。我点击右勾,然后点击向上箭头进行向上投票。超级有用-TY@用户1375291您应该向上投票