Support

Account

Home Forums Add-ons Repeater Field Help with a $wpdb MySQL Query Reply To: Help with a $wpdb MySQL Query

  • Hi @matthewhaigh

    It depends on how you want the subfields to show up. Here’s an example if you want to show any subfields with certain value:

    $rows = $wpdb->get_results($wpdb->prepare( 
        "
        SELECT * 
        FROM {$wpdb->prefix}postmeta
        WHERE
            ( meta_key LIKE %s AND meta_value = %s) OR
            ( meta_key LIKE %s AND meta_value = %s)
        ",
        'colours_%_colour', 'red',
        'images_%_type', 'type_3'
    ));

    You can combine it with any keys and values you want. To learn more about the AND and OR syntax, please take a look at this page: http://www.hackingwithphp.com/9/3/13/multiple-where-conditions.

    Also, I’m afraid this is a MySQL topic. For further support, please visit WordPress support forum or MySQL community instead.

    Thanks πŸ™‚