lundi 4 juillet 2016

Square ([]) brackets not being recognized in text column of sql

I have a column in a SQL table that contains json lists as text.

I want to find all the rows that have [7] in the column. So I have something like the following

SELECT col1, col2 FROM tbl1 WHERE col2 LIKE '[7]'

However this comes back with nothing (though I can see rows when I inspec the table that have that in the field).

Stranger still, if I try editing the query to the following

SELECT col1, col2 FROM tbl1 WHERE col2 LIKE '%[7]%'

It will find the rows that have [7], but it will also get rows that clearly (I think) violate that pattern, i.e. rows that have [1,7]

Is the square bracket something special that I'm not aware of?

Aucun commentaire:

Enregistrer un commentaire