How to COUNT MySQL results when I use “GROUP_CONCAT” and “HAVING” in the query?

mesqueeb

So I have a MySQL query that I want to count. Originally I use wordpress' get_results("") but I also need to count the total in a different query, because in my original query I LIMIT the results to create pages.

So this is my original query, does anyone know how I can count this?

SELECT wpp.ID, post_title, wp_terms.name AS category, wp_terms.slug AS slug, supplier_company, 
    GROUP_CONCAT(wp_terms.slug SEPARATOR ', ') AS allslug,
    GROUP_CONCAT(wp_terms.name SEPARATOR ', ') AS allcatname
    FROM wp_posts AS wpp
    LEFT JOIN wp_term_relationships ON wpp.ID = object_id
    LEFT JOIN wp_terms ON term_taxonomy_id = wp_terms.term_id
    LEFT JOIN wp_teleapo_supplier AS s ON wpp.post_author = s.ID



    /* BASIC SEARCH on normal fields */
    WHERE post_type = 'post' 


    GROUP BY wpp.ID

    /* SEARCH on CONCAT FIELDS*/
    HAVING

    (post_title LIKE '%%'
    OR allcatname LIKE '%%'
    OR allslug LIKE '%%'
    OR supplier_company LIKE '%%')
    AND (allslug LIKE '%health-and-beauty%'
    ) AND (allslug LIKE '%%'
    ) AND 

    /* ADD EXTRA SEARCH TAGS: */
    /* Language tag */
     allslug LIKE '%english%' 
    /* ..... tag */

    /* AND allslug LIKE '%......... %' */
    ORDER BY post_date DESC 
Dylan Su

Just retrieve found_rows directly after your SELECT query.

select found_rows();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to use select query in a Group_concat sub query in mysql

From Dev

Error when I used GROUP_CONCAT on mysql query

From Dev

Query is not executing properly when I use GROUP_CONCAT with in keyward

From Dev

MYSQL get count of search results with group_concat

From Dev

Count group_concat results

From Dev

mysql query, how can i get top 5 downloads with GROUP_CONCAT

From Dev

mysql query, how can i get top 5 downloads with GROUP_CONCAT

From Dev

MySQL: How to sort when using concat in group_concat?

From Dev

MySQL: How to sort when using concat in group_concat?

From Dev

How to use GROUP_CONCAT in mySQL when one of the fields contain comma seperated numbers?

From Dev

How do I use JPA 2.1's CriteriaBuilder.function with MySQL's "GROUP_CONCAT"?

From Dev

MySQL group_concat and count

From Dev

MySQL use GROUP_CONCAT when INSERTing data

From Dev

Mysql GROUP_CONCAT and IN query

From Dev

mySQL GROUP_CONCAT - Query

From Dev

how to use GROUP_CONCAT of two columns with query

From Dev

MySQL - Having problems with COUNT() in query with GROUP BY

From Dev

Single MySQL query summing results between a date and having count

From Dev

How to use GROUP_CONCAT with MAX(CASE WHEN...)?

From Dev

How can I use GROUP_CONCAT in Rails?

From Dev

How can I use group_concat on an entire subquery?

From Dev

Mysql group_concat of repeated keys and count of repetition of multiple columns in 1 query ( Query Optimization )

From Dev

MySQL - Using COUNT() to return total results when HAVING is specified

From Dev

Displaying Mysql Group_Concat results with Bootstrap

From Dev

How to use GROUP By and HAVING in MySQL

From Dev

Mysql Group_concat where in again group concat how can i manage

From Dev

MySQL : GROUP_CONCAT the column and its count

From Dev

Mysql group_concat for count in sub query using parent filed is not allowed

From Dev

Optimize MySQL query for group_concat function

Related Related

  1. 1

    how to use select query in a Group_concat sub query in mysql

  2. 2

    Error when I used GROUP_CONCAT on mysql query

  3. 3

    Query is not executing properly when I use GROUP_CONCAT with in keyward

  4. 4

    MYSQL get count of search results with group_concat

  5. 5

    Count group_concat results

  6. 6

    mysql query, how can i get top 5 downloads with GROUP_CONCAT

  7. 7

    mysql query, how can i get top 5 downloads with GROUP_CONCAT

  8. 8

    MySQL: How to sort when using concat in group_concat?

  9. 9

    MySQL: How to sort when using concat in group_concat?

  10. 10

    How to use GROUP_CONCAT in mySQL when one of the fields contain comma seperated numbers?

  11. 11

    How do I use JPA 2.1's CriteriaBuilder.function with MySQL's "GROUP_CONCAT"?

  12. 12

    MySQL group_concat and count

  13. 13

    MySQL use GROUP_CONCAT when INSERTing data

  14. 14

    Mysql GROUP_CONCAT and IN query

  15. 15

    mySQL GROUP_CONCAT - Query

  16. 16

    how to use GROUP_CONCAT of two columns with query

  17. 17

    MySQL - Having problems with COUNT() in query with GROUP BY

  18. 18

    Single MySQL query summing results between a date and having count

  19. 19

    How to use GROUP_CONCAT with MAX(CASE WHEN...)?

  20. 20

    How can I use GROUP_CONCAT in Rails?

  21. 21

    How can I use group_concat on an entire subquery?

  22. 22

    Mysql group_concat of repeated keys and count of repetition of multiple columns in 1 query ( Query Optimization )

  23. 23

    MySQL - Using COUNT() to return total results when HAVING is specified

  24. 24

    Displaying Mysql Group_Concat results with Bootstrap

  25. 25

    How to use GROUP By and HAVING in MySQL

  26. 26

    Mysql Group_concat where in again group concat how can i manage

  27. 27

    MySQL : GROUP_CONCAT the column and its count

  28. 28

    Mysql group_concat for count in sub query using parent filed is not allowed

  29. 29

    Optimize MySQL query for group_concat function

HotTag

Archive