Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Extract User Interests | JSON Functions
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Functions in SQL

bookChallenge: Extract User Interests

After learning the essentials of JSON functions in SQL, you are ready to tackle a practical challenge that involves working with structured data stored in a JSON column. The user_profiles table contains user information, where the profile_data column holds JSON objects. Each object includes user attributes such as age, address, and most importantly for this task, an interests array. Your goal is to extract this interests array for each user using SQL's JSON functions.

Tâche

Swipe to start coding

Write a query to retrieve each user's user_id and the corresponding interests array from the profile_data JSON column in the user_profiles table.

  • Select the user_id column.
  • Extract the interests array from the profile_data JSON column.
  • Return one row per user, including both the user_id and extracted interests array.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 6. Chapitre 2
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Suggested prompts:

How can I write a SQL query to extract the interests array from the profile_data column?

Can you show an example of extracting the interests array for all users?

What if some users don't have an interests array in their profile_data?

close

bookChallenge: Extract User Interests

Glissez pour afficher le menu

After learning the essentials of JSON functions in SQL, you are ready to tackle a practical challenge that involves working with structured data stored in a JSON column. The user_profiles table contains user information, where the profile_data column holds JSON objects. Each object includes user attributes such as age, address, and most importantly for this task, an interests array. Your goal is to extract this interests array for each user using SQL's JSON functions.

Tâche

Swipe to start coding

Write a query to retrieve each user's user_id and the corresponding interests array from the profile_data JSON column in the user_profiles table.

  • Select the user_id column.
  • Extract the interests array from the profile_data JSON column.
  • Return one row per user, including both the user_id and extracted interests array.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 6. Chapitre 2
single

single

some-alt