I guess one could argue that this is somewhat wordpress related, because you are trying to get_results()
from $wpdb
, but like @MarkKaplun said your problem is that you are using the SQL wrong. Below code is an example on how to do it correct:
$dr = $wpdb->get_results(
$wpdb->prepare(
"SELECT * FROM wp_shipping WHERE country = %s AND ID = %d",
$country, $ids
)
);
This is an example, you might have to fit it to your needs. For additional information you should take a closer look at the codex Class Reference: wpdb.
Related Posts:
- How to display SQL query that ran in query?
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- wpdb get posts by taxonomy SQL
- Multipart/formatted MySQL query problem
- WordPress creating excessive joins on meta_query with search
- cron job to auto delete posts of a specific post type older than x days
- Are database queries created using WordPress filters protected from SQL injection?
- Get posts by category with pure SQL query
- Custom query to get terms from post ids
- Get the timout value of a saved transient?
- What’s wrong with my $wpdb prepare?
- How do I see the mysql query generated by get_posts( $args )?
- sql select query in wordpress ‘page’ [closed]
- problem with sql query in wordpress plugin
- Attempt to improve WP search, can someone check my SQL query?
- wpdb query problem to access previous 3 days posts
- I can’t figure out what’s wrong with this statement. $wpdb->query update
- Custom Query – Based on user input
- how to insert missing tags into the posts through mySQL?
- $wpdb->prepare affecting the query?
- WordPress SQL search, how to handle SQL Injection?
- exclude pingbacks from wordpress SQL query
- prepare function sql safe method
- WordPress SQL query to tag all posts containing a specific word on title
- How do I query for posts by custom meta and those that have been stickied?
- Change pure SQL database query to WordPress post query?
- Cannot get sql request from Query object?
- I want to get on those users their meta value are like “AGENT” .. but this query is not working
- Display data from phpMyAdmin with WordPress
- SQL to Query the db and return all posts and it’s metas
- SQL query to delete users with multiple meta keys and comments
- Nested select statements not working
- Speed up search query that searches in post meta?
- Are there any best practices for creating a Like/Favourite feature in WordPress using custom MySQL tables and without any plugins?
- Fastest and most efficient SQL query to check if UID exists
- How to make MySQL search queries with quotes
- How i make a custom sql query for Woocommerce
- $wpdb query for price in custom field value
- Run an update query in a function
- How to display a specific category using a custom Query in WordPress?
- Slow query when joining wp_posts with a lookup-table?
- Wpdb generates too many queries
- learn to run wpdb class
- SQL Query : how copy all tags of post into their post content in wordpress by sql query
- Where can I find the SQL to get the most used information by wordpress database?
- Custom Query for wp_posts using wp_postmeta
- 3 queries to update WordPress
- Get all image from single page using this query
- Add multiple value to a query variable in WordPress
- How to tune search argument in WP_Query to show only exactly the same results?
- How to get my loop to pull posts into three columns
- Can’t pass table to $wpdb->prepare
- Change SQL get_results to search for posts with custom term in custom taxonomy
- Date query year and month OR just year
- get post id using the $query_vars variable
- Is there a conditional tag for latest post or do i need a query?
- How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?
- get_posts() loop returns the same the_title() for each post
- How select a specific query when setting offset?
- Temporarily storing main search result
- Help with MySQL to $WPDB query
- Order by summing multiple values
- wpdb->term_taxonomy count posts from both published and private posts?
- Group custom post listing in admin section
- List author’s posts with SQL
- Where is the query in wp-login.php
- Order posts by recent comments
- query if page has not child
- get_posts showing only 5 posts. (nopaging and posts_per_page -1 not working)
- Order by title – but now built in wordpress func, sort the_title
- pre saved posts query from db options table
- Order posts by date, but also give priority for a specific term
- Custom Query returns array, but I can’t see it’s elements
- How to insert Collate into WordPress search query?
- Combine “Exclude” Query in functions.php
- Optimize slow SQL query for multiple meta values
- Wrap/close ‘query’ for a first-letter ordered listing of posts
- wpdb query with dynamic column name?
- How do you display the number of a post in a query?
- How to return count of custom post type posts with a specific custom field value via $wpdb?
- How to rearrange a pool of posts joined using two queries?
- wpdb update multiple row?
- Can I include get_posts in this array?
- Custom query Custom-Post-Types creates error
- Formatting a date/time returned from a custom $wpdb query
- Rewrite rule for query params
- Hook into the Admin Dashboard and redirect users
- Job and Employee Performance Tracking with Product Safety
- Displaying data from custom table
- SEO friendly query vars
- Prevent versioning for .woff (font) files
- Orderby event date (if it exists) or post date (if it doesn’t) – how to reorder posts based on meta value OR date
- OR condition not working
- Query not returning child posts for any parent post ID
- Use $wpdb->get_results with filter based on array
- Add Hook for clearing transient when post is added
- Show links to child pages on both parent AND child pages
- Modify Global Posts Plugin
- How to reference same column name but different table in custom db query
- Retrieving custom field array value through db query