I have a Joomla (3.9.13) database that contains a table called fields_values
, it is a denormalized key value store (so i've been told). It contains the following data;
+----------+---------+--------+
| field_id | item_id | value |
+----------+---------+--------+
| 6 | 119 | bloggs |
| 17 | 119 | 1 |
| 19 | 119 | 45 |
| 21 | 119 | 55 |
| 17 | 119 | 14 |
| 17 | 119 | 100 |
+----------+---------+--------+
When I run this query;
SELECT `field_id`
, `item_id`
, `value`
FROM `fields_values`
WHERE `field_id` IN (6,17) AND `item_id` = '119'
I get these results;
+----------+---------+--------+
| field_id | item_id | value |
+----------+---------+--------+
| 6 | 119 | bloggs |
| 17 | 119 | 1 |
| 17 | 119 | 2 |
| 17 | 119 | 13 |
| 17 | 119 | 14 |
| 17 | 119 | 100 |
+----------+---------+--------+
That all seems fine, but when I run this query (omit the 6
from IN
clause);
SELECT `field_id`
, `item_id`
, `value`
FROM `fields_values`
WHERE `field_id` IN (17) AND `item_id` = '119'
I get zero results.
I would have expected the following results;
+----------+---------+--------+
| field_id | item_id | value |
+----------+---------+--------+
| 17 | 119 | 1 |
| 17 | 119 | 2 |
| 17 | 119 | 13 |
| 17 | 119 | 14 |
| 17 | 119 | 100 |
+----------+---------+--------+
I've also tried this simple version of the query;
SELECT
`field_id`,
`item_id`,
`value`
FROM
`o3m0z_fields_values`
WHERE
`field_id` = 17
AND
`item_id` = '119'
I get zero results.
Here's the table information taken from HeidiSQL;
I've tried to replicate this on a fresh Joomla install and I can't. Why is this happening?
Note: I can't change the query as it's generated by the core Joomla system.