I have this JSON data, which I got from an API:
[
{
"guide_id": 1,
"uuid": "AAAA"
},
{
"guide_id": 2,
"uuid": "BBBB"
},
{
"guide_id": 3,
"uuid": "CCCC"
},
{
"guide_id": 4,
"uuid": "DDDD"
}
]
I have data in the ‘guide’ table:
guide_id | name |
---|---|
1 | guide A |
2 | guide B |
3 | guide C |
How can do select in the guide table to get ‘guide_id’, ‘name’, and ‘uuid’? Maybe put this JSON data I collected as temporary table?
SELECT guide_id, name,
<Something else to refer to the JSON data I have collected> as uuid
FROM guide
So I like to have the result as
guide_id | name | uuid |
---|---|---|
1 | guide A | AAAA |
2 | guide B | BBBB |
3 | guide C | CCCC |
2
Answers
You will need to Import JSON data into your MySQL database
The command you need will take the form
mysqlsh user@localhost:33062 --import /europe/regions.json regions jsondata --schema=mydb
once you have it in your database you can use a standard SQL query to join it to your other table
No it is not like that you need to fetch your file if it is a json file and then .map your data for show what you need in your file.
Look fetch a json file with javascript and next time put more information for understand your issue, because you use another language and we can not know.
Like you show it is when you use a real db and not a json file like sql.