sql >> Database >  >> RDS >> Mysql

Hoe worden categorieën en subcategorieën voor WooCommerce opgeslagen in DB?

function getParentCategories() {
    global $wpdb;
    $sql = "SELECT term_id as id, name, slug FROM wp_terms where term_id in (SELECT term_id FROM wp_term_taxonomy where parent = 0 and taxonomy = 'category') order by name asc";
    $parents = $wpdb->get_results( $sql );
    return $parents;
}

function getChildCategories($id) {
    global $wpdb;
    $sql = "SELECT term_id as id, name, slug FROM wp_terms where term_id in (SELECT term_id FROM wp_term_taxonomy where parent = $id and taxonomy = 'category')  order by name asc";
    $children = $wpdb->get_results( $sql );
    return $children;
}


  1. Inzicht in 'datetimeoffset' opslaggrootte in SQL Server

  2. Wat is hier mis met mijn SQL? #1089 - Onjuiste prefixsleutel

  3. Verschil tussen VARCHAR en TEXT in MySQL

  4. Meerdere rijen invoegen in een enkele SQL-query - Interviewvraag van de week #069