Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

MySQL does not support arrays directly, but you can use a combination of tables and SQL queries to achieve similar functionality.

One approach is to create a separate table to store your array values, using the key as a column:

CREATE TABLE my_array (
  key_name VARCHAR(255) PRIMARY KEY,
  value VARCHAR(255)
);

Then, you can insert values into this table:

INSERT INTO my_array (key_name, value)
VALUES ('key1', 'value1'), ('key2', 'value2'), ('key3', 'value3');

To retrieve the value of a specific key, you can use a SELECT query:

SELECT value FROM my_array WHERE key_name = 'key2';

This will return the value associated with the "key2" key.