Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Which query method to use? (edit- wpdb syntax problems)

This will work fine.

 global $wpdb;
 $querydetails = "
SELECT
    wposts.*
FROM 
    $wpdb->posts AS wposts
INNER JOIN 
    $wpdb->postmeta AS wpostmeta ON wposts.ID = wpostmeta.post_id
WHERE
    wposts.post_status="publish" 
AND wposts.post_type="match_report"
AND wpostmeta.meta_key = 'report_home-select'
AND wpostmeta.meta_value="198" 
";

$teaminfo = $wpdb->get_results($querydetails, OBJECT);

Try it.

Related Posts:

  1. Most efficient way to get posts with postmeta
  2. How to get all term meta for a taxonomy – getting term_meta for taxonomy
  3. Query between two meta values?
  4. Short of raw SQL, can I query for multiple attachment metadata that have a given array key?
  5. Triple meta_key on custom SELECT query
  6. Get updated post meta on save_post action?
  7. Get post from meta_key and meta_value
  8. WP_POSTMETA changes site crash
  9. Select from wp_post and multiple meta_value from wp_postmeta
  10. MySQL Query To Select Post By Postmeta
  11. Set Condition echo function get_post_meta
  12. Get a row from a separate table by matching a posts meta_key to a tables ID column
  13. Compare string with post id in wpdb and do stuff when match is found
  14. cleaning up safely wordpress wp_postmeta table
  15. Read post meta values, only if posts are public
  16. How to test the outcome of a wpdb query?
  17. How do I insert a new meta key / value pair, but only if another meta key is present?
  18. mass delete posts based on metadata
  19. Duplicate rows in meta table, any known relations in WC?
  20. Need a SQL query to update meta_key=’_price’ with value in meta_key=’_regular_price’
  21. wpdb->get_var – count author posts, meta value
  22. How to query and update one colum in postmeta table?
  23. Display current ranking of post as a number in post title
  24. SQL query – get a featured image’s alt / alternative text
  25. get specific values from WordPress meta_value
  26. Get data from custom table and update relative post_meta based on meta_key
  27. Removing Malware
  28. Get table parameter and save in meta value
  29. Exclude category from DB query
  30. Fetching array of postmeta with $wpdb and in_array conditional
  31. Cache metadata for set of posts
  32. How to get all the related ids without array?
  33. How do I retrieve the slug of the current page?
  34. How do you properly prepare a %LIKE% SQL statement?
  35. Get posts by meta value
  36. Explanation of update_post_(meta/term)_cache
  37. How to extract data from a post meta serialized array?
  38. WPDB Insert or if exists Update
  39. How to save an array with one metakey in postmeta?
  40. WordPress is stripping escape backslashes from JSON strings in post_meta
  41. How can I get the post ID from a WP_Query loop?
  42. Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
  43. Pagination with custom SQL query
  44. How to use $wpdb to delete in a custom table
  45. How to update_post_meta value as array
  46. Adding meta tag without plugin
  47. What’s the point of get_post_meta’s $single param?
  48. What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
  49. How to edit a post meta data in a Gutenberg Block?
  50. Sanitizing integer input for update_post_meta
  51. post formats – how to switch meta boxes when changing format?
  52. $wpdb->get_results(…) returns empty array despite correct query
  53. Execute action after post is saved with all related post_meta records (data)
  54. Lack of composite indexes for meta tables
  55. Use wpdb->prepare for `order by` column name
  56. get_results on large datasets
  57. Get a single post by a unique meta value
  58. SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
  59. if get_post_meta is empty do something
  60. How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
  61. How we get_post_meta without post id
  62. How get post id from meta value
  63. What is the code to get the download link for a product in WooCommerce?
  64. Safe to delete blank postmeta?
  65. wpdb get posts by taxonomy SQL
  66. So much data in postmeta
  67. advanced custom fields update_field for field type: Taxonomy
  68. update_post_meta not saving when value is zero
  69. Export WordPress Posts and Meta Information in CSV format
  70. Content hooks vs User hooks
  71. Meta compare with date (stored as string) not working
  72. Display data from a non wordpress database on a page template
  73. Trying to get custom post meta through Jetpack JSON API [closed]
  74. wpdb->prepare function remove single quote for %s in SQL statment
  75. How to update/insert custom field(post meta) data with wordpress REST API?
  76. What is the advantage of the wp_options design pattern?
  77. Restrict post edit/delete based on user ID and custom field
  78. Multipart/formatted MySQL query problem
  79. prepare() not working
  80. get_post_meta returning empty string when data shows in the database
  81. publish_post action hook doesn’t give post_meta_data
  82. Remove WordPress.org Meta link
  83. Remove post meta keys
  84. How to access the post meta of a post that has just been published?
  85. Why time functions show invalid time zone when using ‘c’ time format?
  86. Why is get_post_meta returning an array when I specify it as single?
  87. How to update/delete array in post meta value?
  88. Adding an assisting editor box to Post page
  89. How to display multiple Post meta_key/meta_values by SQL query
  90. Inserting Post Meta From SQL
  91. Retrieving custom fields with $wpdb->get_results
  92. How to make an activities stream mixing posts and comments?
  93. WPDB Multiple site’s posts and get featured images
  94. delete unused postmeta
  95. Should I sanitize custom post meta if it is going to be escaped later?
  96. Add post meta based on another post meta value before publish post
  97. What is an efficient way to query based on post_meta?
  98. How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?
  99. Front-end update_post_meta snippet displays white screen?
  100. Getting users who registered 360 days from current date
Categories post-meta Tags post-meta, sql, wpdb
“regular” pages not found after changing permalink
search page different results

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress