Is there any way to use values from a JSON object in a SQL Select statement?

DM5963

I want to write a query to select all the records where the values in the properties of a JSON object match a given string. For example, let's say I have a table with a column for address, which is a JSON object. The address for the first record looks like this:

{
 "addressLine": "123 fake road"
 "city": "Buffalo"
 "state": "New York"
}

And the address for the second record looks like this:

{
 "addressLine": "123 fake road"
 "city": "New Haven"
 "state": "Connecticut"
}

Would it be possible to write a query given the word 'New’ that would return both records since the values of the JSON contains that string? Thanks!

Hadi

You can use JSON_EXTRACT function:

SELECT * FROM Table WHERE json_extract(JsonColumn, '$.city') like 'New%'

Additional information

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

is there any way to use the values from a list in an sql lite database

Extract values from JSON text field for use in "IN" statement SQL

Is there a way to do a select statement and union 2 column, replacing any NULL values in one with information from the other

SELECT any row that starts with (multiple values from select statement)

Select Columns From Values of other sql statement

Concatenating values from SQL select statement

Is they any way to use postgresql session variable while using select statement

Any way to change a value on ODD/EVEN records in a sql Select statement?

Is there any way to use json objects in SQL

Any way to select unique values from values within a row in MySQL?

Can I use a select statement for inserting values with an object type?

SQL Select different values from same object

Is there a way to use a specified range as variables for SQL select statement?

Way to use glue_sql() and avoid paste in dynamic SELECT statement?

Any way to build up a dictionary / json object of sensor values in esphome?

SQL statement not returning any values

Extract and display values from JSON array in Select Statement in Postgres

How to insert values into database table from select statement SQL

I need to understand the following MS SQL statement ( SELECT FROM VALUES)

Swift 2: Is there any way to use 'default' in the switch statement of enum with associated values?

MySQL How to use values of a column from table A and use values as column names in select statement

SQL Filter Select Statement if occurs in any column

Is there a better way to get specific values from a JSON object?

Is there any alternative way which i can use instead of "<" in CASE Statement? Oracle sql

How to display Values from a Json Object into a Mat-Select

Is there a constant time operation to determine whether a result object from a select statement has any rows?

SQL update statement from select

Is there any way I can use switch statement inside a container in assigning colors to that container from a list of colors

SQL - Select Values From A Table Where A Corresponding Value Matches The Results Of Another Select Statement