Support

Account

Home Forums General Issues Group Query by Custom Field

Unread

Group Query by Custom Field

  • How can I make a query and result group by custom fields

    I have the movie and year fields and would like to query and group the result by those fields so that they do not have repeat values

    +---------+----+---------+----------+-----------------------+--+
    | post_id | id | meta_id | meta_key |      meta_value       |  |
    +---------+----+---------+----------+-----------------------+--+
    |       9 |  9 |      10 | movie    | 264                   |  |
    |       9 |  9 |      12 | year     | a:1:{i:0;s:1:"1991";} |  |
    |      10 | 10 |      13 | movie    | 264                   |  |
    |      10 | 10 |      14 | year     | a:1:{i:0;s:1:"1991";} |  |
    |      11 | 11 |      15 | movie    | 300                   |  |
    |      11 | 11 |      16 | year     | a:1:{i:0;s:1:"2018";  |  |
    |      13 | 13 |      17 | movie    | 300                   |  |
    |      13 | 13 |      18 | year     | a:1:{i:0;s:1:"2018";  |  |
    +---------+----+---------+----------+-----------------------+--+

    I wanted the result to be only:

    9 movie 264
    9 year 1991
    
    13 movie 300
    13 year 2018

    without the repeated values

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.