I agree with @bainternet. You don’t need $wpdb->prepare
. There isn’t any user supplied content.
The answer to the question is that to get a wildcard %
to pass through prepare
you need to double it in your code.
LIKE '_transient_wb_tt_%%'
Try that or this if you want a good look at the generated query:
var_dump($wpdb->prepare("
SELECT option_name
FROM %s
WHERE option_name
LIKE '_transient_wb_tt_%%'
",
'abc'));
die;
Other than being unnecessary, using $wpdb->prepare
like this won’t work. The attempt to use prepare
to swap in the tablename will result in a tablename with quotes around it. That is invalid SQL. The query should be simple:
SELECT option_name
FROM {$wpdb->options}
WHERE option_name
LIKE '_transient_wb_tt_%%'
Related Posts:
- Use wpdb->prepare for `order by` column name
- $wpdb->prepare with LIKE returning blank array instead of rows
- wpdb prepare sql problem
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- SQL WITH clause example [duplicate]
- The wait operation timed out. ASP
- Conversion failed when converting date and/or time from character string while inserting datetime
- how to fix oracle ORA-01722 invalid number error
- SQL query to select dates between two dates
- Must declare the scalar variable
- How can I do a FULL OUTER JOIN in MySQL?
- MySQL query String contains
- How do I escape a single quote in SQL Server?
- How do I import an SQL file using the command line in MySQL?
- mysql Foreign key constraint is incorrectly formed error
- Can a foreign key be NULL and/or duplicate?
- How do I do multiple CASE WHEN conditions using SQL Server 2008?
- How do composite indexes work?
- MySQL “WITH” clause
- Error Code: 2013. Lost connection to MySQL server during query
- SQL join on multiple columns in same tables
- Sql query – getting rid of hard-coded values
- ORA-00918: column ambiguously defined in SELECT *
- Combining “LIKE” and “IN” for SQL Server
- How To Run A Github Repository?
- SQL Switch/Case in ‘where’ clause
- How to run a SQL query on an Excel table?
- SQL Server reports ‘Invalid column name’, but the column is present and the query works through management studio
- Oracle “Partition By” Keyword
- What is the equivalent of ‘describe table’ in SQL Server?
- Add a column with a default value to an existing table in SQL Server
- Remote table-Valued Function Calls are not allowed
- The backend version is not supported to design database diagrams or tables
- Determine ROW that caused “unexpected end of file” error in BULK INSERT?
- Difference between View and table in sql
- What is the purpose of using WHERE 1=1 in SQL statements?
- Exclude a column using SELECT * [except columnA] FROM tableA?
- How do you force mysql LIKE to be case sensitive?
- What is the difference between a stored procedure and a view?
- Why is SQL server throwing this error: Cannot insert the value NULL into column ‘id’?
- pg_ctl: no database directory specified and environment variable PGDATA unset
- ERROR 1148: The used command is not allowed with this MySQL version
- Difference between INNER JOIN and LEFT SEMI JOIN
- SQL conditional SELECT
- ‘CREATE PROCEDURE’ must be the only statement in the batch (Erro)
- PostgreSQL visual interface similar to phpMyAdmin?
- DATEDIFF function in Oracle
- Solutions for INSERT OR UPDATE on SQL Server
- GROUP BY and COUNT using ActiveRecord
- MySQL – Get row number on select
- MySQL error: Unknown column in ‘where clause’
- What is the difference between Views and Materialized Views in Oracle?
- “select * into table” Will it work for inserting data into existing table
- ORA-01735: invalid ALTER TABLE option – Toad
- CASE IN statement with multiple values
- List of special characters for SQL LIKE clause
- How to use $wpdb to delete in a custom table
- wpdb get posts by taxonomy SQL
- wpdb->prepare function remove single quote for %s in SQL statment
- Getting users who registered 360 days from current date
- Querying Email Addresses for a List of Users with Same Last Name?
- How To Write An Inner Join With WP Query
- Really simple query giving error in SQL syntax
- How do I escape a table name or column name in SQL? esc_sql doesn’t do this
- Update user_login, user_nicename, and display_name
- Change sticky status of posts from phpMyAdmin
- WordPress SQL query – returning ‘true’ ‘false’ or ‘null’
- Modify the structure of data returned by $wpdb
- Best Way to Merge a Dev and Live Site to Become a Staging Site?
- Needing to move content from postmeta to posts in sql [closed]
- Querying wpdb using PHP
- Create table from array with prepare
- $wpdb->prepare with ON DUPLICATE KEY UPDATE
- How to import a Typo3 database to a wordpress site?
- Increment integer field in database when WHERE needs to be dynamic [closed]
- Make a SQL query with wpdb in WordPress
- Custom $wpdb returns unexpected time based results
- PHP -> SQL Query with Summing
- How to delete a particular row in a database table
- Get emails from users by custom field SQL
- Clean up very big and very dirty database
- Getting value from database table depending on field value
- How to delete ALL comments from certain category in WordPress database?
- How can I convert everything from category X to have post format Link
- Bulk delete WordPress Post and all metadata, etc using SQL query
- WordPress SQL Prepare
- How to get image path from id using SQL
- How to store sensitive user data (passwords)
- What steps do I need to take to install a local copy of a live website?
- Reset post IDs with all post meta
- Help posting values to DB on submit using $wpdb->query
- How to Add or Change Post Title
- Why does DROP TABLE-ing the `wp_options` reset my user session?
- How to refactor DB queries for better TTFB in WordPress?
- query sql-table and change entities
- Duplicate WP Migration affecting site on separate domain?
- Backtick (MySQL norm) added to SQL Server Query causing error
- $wpdb post type and term query only works when there are no dashes or spaces in the term slug and title
- SQL query to check whether a meta key is set or not for a post in post_meta table
- Firebase with WordPress instead of SQL?