I have a table [JsonTable], and the column [JsonData] save the json string,
JsonData like:
{
"Names": ["John", "Joe", "Sam"]
}
How can I inner join this table like:
SELECT* FROM [TestTable] AS T
INNER JOIN [JsonTable] AS J ON T.[Name] IN JSON_QUERY(J.[JsonData], '$.Names')
You need to use OPENJSON
function for reading Names
array. You can use this query.
SELECT * FROM [TestTable] T
INNER JOIN [JsonTable] AS J ON T.[Name] IN (SELECT value FROM OPENJSON(J.[JsonData],'$.Names'))