如何从同一个列和表中搜索两个元值

I make a custom search in WordPress. There are three fields for searching.

  1. Age
  2. Location
  3. Post Title

enter image description here

Post Title is searched from wp_posts > post_title field and location and age are custom meta fields y_age, y_activity_locations. So there is 6 scenarios of searching.

If user enter:

  1. Enter Title or
  2. Select Location or
  3. Select Age or
  4. Enter Title and Select Location or
  5. Enter Title and Select Age or
  6. Select Location and Select Age

My first 5 (Five) scenarios are working perfectly but my 6th scenario is not working because it comes from same table (wp_postmeta) and same column but two different values.

So I tried this query:

Select y_posts.*, y_meta.*
From wp_posts As y_posts
Inner Join wp_postmeta As y_meta
On y_posts.ID = y_meta.post_id
Where y_posts.post_type = 'download'
And y_posts.post_status = 'publish'
And y_meta.meta_key = 'y_activity_locations' 
And y_meta.meta_value Like '%Armidale%'
And y_meta.meta_key = 'y_age'
And y_meta.meta_value Like '%3 to 5%'

The query is not working because I think sever confused two values from same column.

Select y_posts.*, y_meta.*
    From wp_posts As y_posts
    Inner Join wp_postmeta As y_meta
    On y_posts.ID = y_meta.post_id
    Where y_posts.post_type = 'download'
    And y_posts.post_status = 'publish'
    And y_meta.meta_key = 'y_activity_locations' 
    And y_meta.meta_value Like '%Armidale%'
    Or y_meta.meta_key = 'y_age'
    Or y_meta.meta_value Like '%3 to 5%'

This query works and it gives me only age or location data but i want search both values at a same time.

I also tried sub query (Never tried before)

Select y_posts.*, y_meta.*
From wp_posts As y_posts
Inner Join wp_postmeta As y_meta
On y_posts.ID = y_meta.post_id
Where y_posts.post_type = 'download'
And y_posts.post_status = 'publish'
And y_meta.meta_key = 'y_activity_locations' 
And y_meta.meta_value Like '%Armidale%'
And (Select yy_meta.* From wp_postmeta As yy_meta Where yy_meta.meta_key = 'y_age'
And yy_meta.meta_value Like '%3 to 5%')

But it gives me this error

1241 - Operand should contain 1 column(s)

So please guide me how can I get two values from same column.

Please give me only query suggestions not any other solutions.

Please try following query :

    Select y_posts.*, y_meta.*
    From wp_posts As y_posts
    Inner Join wp_postmeta As y_meta
    On y_posts.ID = y_meta.post_id
    Where y_posts.post_type = 'download'
    And y_posts.post_status = 'publish'
    And (
        (y_meta.meta_key = 'y_activity_locations' 
        And y_meta.meta_value Like '%Armidale%')
        Or (y_meta.meta_key = 'y_age'
        And y_meta.meta_value Like '%3 to 5%')
    )

You try, wordpress query

<?php 
$argsCat = array(   
    'posts_per_page'    => -1,              
    'post_type'        => 'download',
    'meta_key'         => 'y_activity_locations',
    'meta_value'       => '%Armidale%',
    'meta_query' => array(
        'relation' => 'AND',
        array(
            'key' => 'y_age',
            'value' => '3',
            'compare' => '>='
        ),
        'relation' => 'AND',
        array(
            'key' => 'y_age',
            'value' => '5',
            'compare' => '<='
        )
    ),

);  
$normal_array = get_posts($argsCat);

?>