Sunday, January 1, 2023
HomeWordPress Developmentwpdb - SQL/WordPress, checking if column comprises particular textual content (after which...

wpdb – SQL/WordPress, checking if column comprises particular textual content (after which getting rely) not working


I’ve a desk referred to as wp_rsvp. Inside this desk I’ve a column referred to as cot_needed which has the values of “sure” or “no”.

In my desk, I’ve two rows, one the place cot_needed is “sure” and one the place cot_needed is “no”.

I am making an attempt to get a rely of the rows the place cot_needed is the same as “sure”.

To do that, I’ve the next, which I’ve discovered really useful on different SO questions:

$rsvp_table = $wpdb->prefix . 'rsvp';
$cots_needed_count = $wpdb->get_var( "SELECT COUNT(*) FROM $rsvp_table WHERE 'cot_needed' LIKE '%sure%'");

Nonetheless, after I run echo $cots_needed_count; it returns 0, even by way of a row with “sure” exists? The echo ought to print 1.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments