woocommerce offtopic - how to retrieve specific product attribute value in an sql query?

I am looking for some suggestion on how to run a query on wp-term with multiple "same column name as different attr

I am looking for some suggestion on how to run a query on wp-term with multiple "same column name as different attribute name" bottom line I am trying to query woocommerce products + all their attributes in following format:

<thead> <th>name</th> | <th>color</th> | <th>clarity</th> | <th>shape</th> | <th>size</th> 

<tr><td>product 1</td>|<td>H</td>|<td>good</td>|<td>heart</td>| <td>big</td></tr>

with the following code I am only getting one of the attribute but I am not sure how to add the second and third and rest of attribute to this query.

$var = "SELECT p.`ID` AS 'Product ID',
       p.`post_title` AS 'Product Name',
       t.`name` AS 'carat'
       FROM `wp_posts` AS p
       INNER JOIN `wp_term_relationships` AS tr ON p.`ID` = tr.`object_id`
       INNER JOIN `wp_term_taxonomy` AS tt ON tr.`term_taxonomy_id` = tt.`term_id`
       AND tt.`taxonomy` LIKE 'pa_carat%' 
       INNER JOIN `wp_terms` AS t ON tr.`term_taxonomy_id` = t.`term_id`
       WHERE p.`post_type` = 'product'
       AND p.`post_status` = 'publish'"

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745178869a4615323.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信