If you are going to do this is SQL, use a subquery.
SELECT *,
(SELECT meta_value
FROM wp_commentmeta
WHERE meta_key = 'your-meta-key'
AND wp_commentmeta.comment_id = wp_comments.comment_ID LIMIT 1) as comment_author
FROM wp_comments
Instead of the *, enumerate the fields you want but leave out comment_author. Obviously, $wpdb functions to keep the table names straight.
Related Posts:
- $wpdb->get_results(…) returns empty array despite correct query
- WPDB: how to get the value of a field in a custom database table
- Why is variable not working on custom sql query using wpdb?
- Get Current User Id Inside a Loop Returns 0 For a Shortcode
- Get stock by custom meta field on all Woocommerce variable products
- how to delete 30 day old data using PHP [closed]
- Display fields as values in array from external SQL DB
- Querying wpdb using PHP
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- $wpdb->insert() does not Insert record in a table
- Fatal error: Call to a member function query() on a non-object
- How to retrieve the data from the sever and displaying it in a page?
- Use $wpdb or other PHP script method to find/replace in WP database
- How can I add a new row in a separate database when someone registers via WordPress?
- PHP -> SQL Query with Summing
- How to insert wp_users ->user login name to wp_terms when a new user registering?
- Why my query does not run with prepare
- wpdb getting avatars and author url
- Fetching review value using wpdb class
- WP_Query: How to get results from both meta_key options?
- get_terms with specific id order
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- Passing in MySQL prepare statement parameter separately throwing error
- Database SQL query error
- get different meta-data of a complicated query at the same time
- WordPress SQL Prepare
- Creating multiple tables with Plugin
- can I extend the WP_Query class to deal with ‘duplicate’ posts created by joining to wp_posts?
- WordPress search query, how to modify the sql
- Modify post image in full size
- How to return count of items found in SQL query
- SQL Query Search page
- direct query to post_meta table
- Querying multiple meta_keys in WordPress SQL query
- Changing regular db connection to $wpdb
- Can’t send form data to wpdb when URL has query string
- How to sort search result by post_title, then by post_content
- Can i use php sql functions instead of $wpdb?
- wpdb::prepare was called incorrectly
- count number of user comments with a specific comment meta value
- PHP syntax error when using wpdb update?
- Duplicates with WP_Query loop
- my function doesn’t return my post from today
- Use wp_get_recent_posts with search term
- have_posts() execution failure
- Can’t search posts using WP_QUERY inside AJAX Function
- How can I use wp_query to show all product data using just the products ID?
- Getting id of poll from WP database
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- How to store post ID’s in cookie or session to display the same posts later
- auto-populating custom nav with all items from custom post type
- How to pass orderby params to $wpdb->prepare()?
- Create a Blog Template Page
- Exclude posts with specific metadata from search?
- Display an image if odd number of posts in grid
- Why doesn’t PhotoSmash plugin play well with wp_query?
- How to show meta value code HTML after x paragraph
- Form search query – displaying ACF “Post Object” field as results
- get_the_ID() doesnt work
- wpdb Cannot Update column in Database
- change the default order of posts only for specific categories
- How do I prepare strings for insertions as values into a MySQL table?
- How can I split my query result in 2 arrays?
- How to get post category list as select in front-end?
- WPDB – Read and write value from / to database
- Order a WP_Query by meta value where the value is an array
- How do I check if there is a tag in the title
- How to Generate a list of Most Commented post?
- Why won’t this wpdb get_results query return results?
- wordpress sql posts query won’t display the latest post in a specific category
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- orderby meta_value_num is not working, giving default order
- How can I modify this code to make the search box include tags and meta
- WordPress get last inserted user id
- WP_Query for woocommerce products with a pattern as a post_title
- How do I make these combination select filters work when only one dropdown is set? They work in WordPress 5.8.2 but don’t in 5.8.3
- Fetch Data from an external MSSQL Database in a Managed WP hosting
- Ajax filter with loadmore button
- Query by pagename not Working
- Display featured image of post type category
- Delete post meta by serialized meta value
- Getting info about selected posts using one WP_Query
- Rewrite SQL query as a prepared statement and use in foreach loop
- Where to check in PHPmyAdmin / SQL database for subdomain
- For each 3 posts, show a different post type
- Weird Behaviour: Not all WordPress Posts appearing
- Can not manually create a database ( db, user, pass ) for a plugin
- How to merge 2 WordPress sites?
- Query category-specific, paginated posts and allow viewer to change sort order
- wordpress is_main_query() breaks
- allow previews outside wordpress folder (Outsourcing WP previews)
- Advanced Taxonomy query, with 3 post types
- Why does a meta_query break this WP_Query?
- How do I run the following script from my articles page?
- Execute multiple PHP Snippets causes error?
- use wpdb object on other file
- Three different queries on same page
- Warning: Undefined property: wpdb::$question_overview in C:\Wamp.NET\sites\proxyvragenmodule\wordpress\wp-includes\class-wpdb.php
- External WP_Query call from PHP crashed after version update
- WordPress Query with meta_key and order by another meta_key