Records in CPT are as follow
Name Size From Size To
Demo 1 900 6000
Demo 2 5000 6000
Demo 3 750012000
Demo 4 2500 7500
Demo 5 9000 12000
$meta_query = array(
'relation' => 'OR',
array(
array(
'key' => '_size',
'value' => array(1000, 5000),
'type' => 'decimal(10, 2)',
'compare' => 'between'
),
array(
'key' => '_size_to',
'value' => array(1000, 5000),
'type' => 'decimal(10, 2)',
'compare' => 'between'
),
),
);
After applying above meta_query
not able to get actual output
Expected Output
Name Size From Size To
Demo 1 900 6000
Demo 2 5000 6000
Demo 4 2500 7500
Actually it’s working like below SQL’s. Please review once and let me know best fit for this situation.
Right Now
SELECT * FROM test WEHRE _size BETWEEN (1000 AND 5000) OR _size_to BETWEEN (1000 AND 5000)
Trying to do like below
SELECT * FROM test WEHRE 1000 BETWEEN (_size AND _size_to) OR 5000 BETWEEN (_size AND _size_to)