There is a code with which all unique values ​​of the "driver" meta-field are selected.

$drivers_all = $wpdb->get_results("SELECT DISTINCT meta_value FROM wp_postmeta WHERE meta_key = 'driver'); 

Tell me how to add a value to exclude a certain category from the sample?

    1 answer 1

    Try this:

     $drivers_all = $wpdb->get_results("SELECT DISTINCT meta_value FROM wp_postmeta WHERE meta_key = 'driver' AND meta_key!='no_driver'"); 
    • I need to exclude one of the categories in the selection process, such as "cat = -20". - Bphoenix
    • write then instead of meta_key!='no_driver' cat!=20 . I do not know the names of your fields - alias
    • I do not need to exclude the value of one of the meta-fields, I need to exclude CATEGORY (category) from the sample - Bphoenix
    • In your opinion, is the number of the category that is necessary for exclusion stored differently? - alias
    • In general, not otherwise, but I also indicated in the title that this is about wordpress. By analogy with the field does not work - Bphoenix