1Z0-909 · Question #8
The collection col contains all episodes for all seasons for a TV show. Examine this document which has an example of the details for each episode: Which query returns all expisode names from the…
The correct answer is B. SELECT "S.name" FROM col WHERE "S.season" = "1". Caution: There appears to be an error in this answer key. Based on MySQL JSON Document Store syntax, option A is actually the correct answer, not B. Here is an accurate explanation: Why A is correct: MySQL stores JSON documents in a doc column, and the -> operator extracts JSON…
Question
The collection col contains all episodes for all seasons for a TV show. Examine this document which has an example of the details for each episode:
Which query returns all expisode names from the first season?
Exhibit
Options
- ASELECT doc->"$.name" FROM col WHERE doc->"$.season" = "1";
- BSELECT "S.name" FROM col WHERE "S.season" = "1";
- CSELECT doc-?,$.name,, FROM col WHERE doc-?quot;$ . seas"t; "t"t;;
- DSELECT name FROM col WHERE season = 1;
How the community answered
(30 responses)- B90% (27)
- C3% (1)
- D7% (2)
Explanation
Caution: There appears to be an error in this answer key. Based on MySQL JSON Document Store syntax, option A is actually the correct answer, not B. Here is an accurate explanation:
Why A is correct: MySQL stores JSON documents in a doc column, and the -> operator extracts JSON field values using path expressions. doc->"$.name" retrieves the name field and doc->"$.season" = "1" filters for season 1 - this is the valid, standard syntax for querying MySQL document collections.
Why B is wrong: Wrapping S.name and S.season in double quotes makes them string literals, so the query would return the text "S.name" and compare the literal string "S.season" to "1" - it never touches actual document data.
Why C is wrong: The query is syntactically garbled (likely a display/formatting error in the exam) and would not parse at all.
Why D is wrong: It treats col as a relational table with plain columns (name, season), but document collections store data inside a JSON doc column - there are no bare name or season columns to reference.
Memory tip: For MySQL JSON documents, think doc->"$.fieldname" - the dollar sign $ means "root of the document," just like $ in many scripting contexts means "the whole thing."
I'd strongly recommend flagging this to your instructor, as the stated correct answer (B) does not match standard MySQL JSON Document Store syntax.
Topics
Community Discussion
No community discussion yet for this question.
