Difference Between column path operator ( ->) vs inline path operator (->>) in MySQL 8

MySQL stores JSON documents in an internal format that allows quick read access to document elements.
The JSON binary format is structured in the way that permits the server to search for values within the JSON document directly by key or array index,
which is very fast.
While selecating a particular node from JSON data we have to use column path operator ( ->) i.e jsondata->’$.name’ name and we can also select the using inline path operator (->>) in i.e jsondata->>’$.name’ MySQL 8.
{Read:- 5 Ways to Improve SEO on Your WordPress Site }
Difference Between ( ->) vs (->>) JSON Data Type in MySQL 8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
CREATE TABLE events( id int auto_increment primary key, data json ); INSERT INTO events(data) VALUES ( '{ "name": "Safari", "os": "Mac", "resolution": { "x": 1920, "y": 1080 } }' ); SELECT id, data->'$.name' browser FROM events; <strong>Result:</strong> +----+-----------+ | id | browser | +----+-----------+ | 1 | "Safari" | +----+-----------+ SELECT id, data->>'$.name' browser FROM events; <strong>Result:</strong> +----+-----------+ | id | browser | +----+-----------+ | 1 | Safari | +----+-----------+ |
Notice that data in the browser column is surrounded by quote marks when we are using column path operator ( ->), by using inline path operator (->>) you can remove the quote marks.
{Read:- How to Build a WordPress Site in 1 Day }