[thelist] searching and JSON

Renoir Boulanger renoirb at gmail.com
Wed Sep 12 20:51:01 CDT 2012


An other thing to consider is:

Do you want to make this quicker and a bit permanent. As in. You will extend existing code and do frequent such queries?

If yes.

Options  could be:

1. Create a column that would be parsed out of that field 

by:
- a ""migration"" script in a timely fashion 
- A trigger from an insert on the table could be used to compute new entry's associated re computed value

OR

2. Create a ""View"" table
Think of it as a select statement with operations (CONCAT, JOIN, etc) that the mysql server keeps and you can query as a table


Hope that makes this a auicker to process solution that would also simplify code.

--
Renoir Boulanger
http://renoirboulanger.com/

(envoyé de mon téléphone)
~

On 2012-09-12, at 20:14, "Nadeem Hosenbokus" <nadeem at nadeemh.com> wrote:

> Hi,
> 
> So if the JSON data looks something like this:
> {"Foo":"Bar"},{"Foo2":"Bar2"},{"Foo3":"Bar3"} in a column called
> 'Table.ColumnA'
> 
> Then a query like this should work: [select ColumnA from Table where ColumnA
> like '%{"Foo":%';] if you want all the records that contain the "Foo"
> parameter.
> 
> Or, [select ColumnA from Table where ColumnA like '%:"Bar"}%';] to match all
> the records that have a "Bar" value
> 
> Or, [select ColumnA from Table where ColumnA like '%{"Foo":"Bar"}%';] to
> match all records that have the specific pair value
> 
> Using the colon and curly brackets in the like condition can help you get
> the data you want.
> 
> Hope this helps.
> 
> Nadeem Hosenbokus
> (230) 766 9169
> www.nadeemh.com
> 
> 
> 
> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Bob Meetin
> Sent: 13 September 2012 02:28
> To: thelist at lists.evolt.org
> Subject: [thelist] searching and JSON
> 
> So you're working with a table that has parameterized data stored in a JSON
> formatted field.  How do you create a mysql query that matches against only
> a single element/parameter in the field without matching the other stored
> elements?
> 
> -Bob
> -- 
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt ! 
> 
> -- 
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt ! 


More information about the thelist mailing list