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'”
Read more here:: how to retrieve specific product attribute value in an sql query?