1
I have two tables:
CREATE TABLE jtable (id integer, jdata JSON);
INSERT INTO jtable(id, jdata) VALUES(1, '["1","2","3"]');
INSERT INTO jtable(id, jdata) VALUES(2, '["1","3"]');
INSERT INTO jtable(id, jdata) VALUES(3, '["2","3"]');
| id | jdata |
|---|---|
| 1 | ["1","2","3"] |
| 2 | ["1","3"] |
| 3 | ["2","3"] |
CREATE TABLE informacoes(id integer, value varchar(10));
INSERT INTO informacoes(id, value) VALUES(1,"valor1");
INSERT INTO informacoes(id, value) VALUES(2,"valor2");
INSERT INTO informacoes(id, value) VALUES(3,"valor3");
| id | value |
|---|---|
| 1 | valor1 |
| 2 | value2 |
| 3 | Valor3 |
On the table jtable have a column jdata guy JSON in the Mysql.
That column jtable.jdata will always contain contains an array of integers.
I ask you:
It is possible to relate these integers in the column jtable.jdata to the ids table information(informacoes.id), in order to obtain this structure?
| jtable id | value information |
|---|---|
| 1 | valor1 |
| 1 | value2 |
| 1 | Valor3 |
| 2 | valor1 |
| 2 | Valor3 |
| 3 | value2 |
| 3 | Valor3 |
I tried doing the INNER JOIN with the result of JSON_SEARCH but I was unsuccessful:
SELECT
jtable.jdata,
informacoes.value,
JSON_SEARCH(jtable.jdata,'all',informacoes.id)
FROM jtable
INNER JOIN informacoes
@Augustovasques, although it does not seem, but the tables I am using are exactly as I put there, I did them to try to reach the understanding of the query, but I confess that I am very difficult.
– Wees Smith
I’m just trying to bring the table values information that is in json table json, but I’m not getting it.
– Wees Smith
Perfect @Augustovasques
– Wees Smith