Please suggest any MySQL 5.5+ Engine that can support collection of key-value pairs be stored in any column of a table.
I don't know if this feature is available out of the box in MySQL like PostgreSQL equivalent to HSTORE which is immensely useful and adds some of NoSQL benefits ..
Example in PostgreSQL -
SELECT 'a=>1,a=>2'::hstore;
hstore
----------
"a"=>"1"
source - http://www.postgresql.org/docs/current/static/hstore.html
-
2Somewhat similar post: stackoverflow.com/q/2465294/398670Craig Ringer– Craig Ringer2013年03月22日 11:15:46 +00:00Commented Mar 22, 2013 at 11:15
1 Answer 1
-- For MySQL 5.7+
CREATE TABLE your_table_5_7 (
id INT PRIMARY KEY,
data JSON
);
INSERT INTO your_table_5_7 (id, data)
VALUES (1, '{"a": 1, "b": 2}');
SELECT data->'$.a' AS value_a, data->'$.b' AS value_b
FROM your_table_5_7;
answered Jul 16, 2023 at 17:22
lang-sql