This page redirects to an external site: https://developer.wordpress.org/reference/functions/get_meta_sql/
Given a meta query, generates SQL clauses to be appended to a main query.
<code style="color: #000000"><span style="color: #0000BB"><?php get_meta_sql</span><span style="color: #007700">( </span><span style="color: #0000BB">$meta_query</span><span style="color: #007700">, </span><span style="color: #0000BB">$type</span><span style="color: #007700">, </span><span style="color: #0000BB">$primary_table</span><span style="color: #007700">, </span><span style="color: #0000BB">$primary_id_column</span><span style="color: #007700">, </span><span style="color: #0000BB">$context </span><span style="color: #007700">); </span><span style="color: #0000BB">?></span></code>
(array) array( 'join' => $join_sql, 'where' => $where_sql ).
<?php $meta_query = array( array( 'key' => 'color', 'value' => 'blue', 'compare' => 'NOT LIKE' ) ); global $wpdb; $meta_sql = get_meta_sql( $meta_query, 'post', $wpdb->posts, 'ID' );
Output depending on the meta query:
Array
(
[join] => INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)
[where] => AND ( (wp_postmeta.meta_key = 'color' AND CAST(wp_postmeta.meta_value AS CHAR) NOT LIKE '%blue%') )
)
Since: 3.2.0
get_meta_sql() is located in wp-includes/meta.php.