Retrieving Results Filtered by WP_Tax_Query – GenerateWP
In this third part of our series, after presenting the WP_Meta_Query and the WP_Date_Query Generators, we are introducing the WP_Tax_Query Generator which allows you to filter queries by taxonomies. Filtering by Taxonomies
Retrieving filtered data with WP_Query and other supported query classes is a no brainier. But for advanced filtering we may need to retrieve data assigned to a specific multiple categories, tags or any other taxonomy terms.
WordPress stores taxonomy-related data in separate database tables. wp_terms holds the term data. wp_term_relationships stores the relationships between terms (category, tag, custom) and an object (mostly posts but can be used for other objects in WordPress – like Users or Comments). wp_term_taxonomy describes the taxonomy (category, link or tag) for the entries in the wp_terms table.
To retrieve data from those tables it translates query data and conditions to SQL. But you shouldn’t write your own SQL – it’s a bad practice! WordPress will do it for you, in a secure way, with caching and other mechanisms that ensure maximum performance and utilization.
The WP_Query class retrieves taxonomy-related data using the tax_query
Source: https://managewp.org/articles/14125/retrieving-results-filtered-by-wp-tax-query-generatewp

source https://williechiu40.wordpress.com/2017/01/04/retrieving-results-filtered-by-wp_tax_query-generatewp/