how to retrive the number of rows returned from a query that uses CONCAT?
-
Hello,
I’m currently building a plugin that has a custom search form. In the query, I make use of CONCAT together with an alias and use that in the search along with LIKE. At the moment I’m having trouble returning the number of results found from the search. I tried to use COUNT but that didn’t work. My query looks something like this (I’m sorry, I would have copied the actual one it’s just that I’m typing this over my phone):
$query = "SELECT id, CONCAT('book_title', ' ', 'volume', ' ', 'ref') as full_title FROM " . $book_table . " WHERE id LIKE '%$book_id%'"; $results = $wpdb->get_results($query);
Now, I’m able to carry out the search and it works however I can’t return the number of rows available from the search along with the array. How can I return the number of rows as well? I’ve used num_rows along with COUNT and num_rows without COUNT.
What I want is, for example, “5 result(s) found” to appear.
Thanks!
- The topic ‘how to retrive the number of rows returned from a query that uses CONCAT?’ is closed to new replies.