You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT `m`.`Id`, `m`.`ArrayValues`
FROM `MyTable` AS `m`
WHERE 15 IN (
SELECT `a`.`value`
FROM JSON_TABLE(`m`.`ArrayValues`, '$[*]' COLUMNS (
`key` FOR ORDINALITY,
`value` int PATH '$[0]'
)) AS `a`
)
This return zero rows when performed on the table above. I don't know exactly why it doesn't work. I've experimented a lot with the SQL but I've never gotten it to return anything.
What does work, however, is json_contains():
SELECT *
FROM MyTable
WHERE JSON_CONTAINS(ArrayValues, '15')
This returns the correct rows.
MySQL version: 8.0.31
Operating system: Windows Server 2016
Pomelo.EntityFrameworkCore.MySql version: 8.0.2
Microsoft.AspNetCore.App version: .net8.0
The text was updated successfully, but these errors were encountered:
When you use
.Contains()
in a.Where()
then a key/value list is generated usingjson_table()
and aWHERE X IN
is used to search in it.Take this table:
With this entity:
And the following code to get data:
Will generate the following SQL:
This return zero rows when performed on the table above. I don't know exactly why it doesn't work. I've experimented a lot with the SQL but I've never gotten it to return anything.
What does work, however, is
json_contains()
:This returns the correct rows.
MySQL version: 8.0.31
Operating system: Windows Server 2016
Pomelo.EntityFrameworkCore.MySql version: 8.0.2
Microsoft.AspNetCore.App version: .net8.0
The text was updated successfully, but these errors were encountered: