Find users whose comma-separated skills list contains Python as a whole skill

Quick Overview

Write a SQL query that finds users whose comma-separated skills string contains Python as a complete skill, without matching names such as MicroPython or Python3. It tests token matching with anchored regular expressions or string splitting, along with NULL and empty-string handling.

Find users whose comma-separated skills list contains Python as a whole skill

Company: LinkedIn

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

`UserProfile` stores each user's skills as one comma-separated string, for example `'Java,Python,SQL'`. Find the users whose `skills` include `Python` as a complete skill. Substrings like `MicroPython` or `Python3` must not match. Return `user_id`, `name` and `skills`, ordered by `user_id` ascending. ```hint Token boundaries Think about what can sit immediately before and immediately after `Python` when it is a whole item in the list. ``` ### Input Table(s) `UserProfile` | Column | Type | Meaning | |---|---|---| | user_id | INT | The user | | name | VARCHAR(100) | The user's name | | skills | VARCHAR(500) | Comma-separated skill names, may be NULL or empty | Primary key: `user_id`. ### Output Contract | Column | Meaning | |---|---| | user_id | The matching user | | name | The user's name | | skills | The original `skills` string, unchanged | Return one row per matching user, ordered by `user_id` ascending. ### Example `UserProfile` | user_id | name | skills | |---|---|---| | 1 | Alice | Java,Python,SQL | | 2 | Bob | C++,Go | | 3 | Carol | Python | | 4 | Dave | MicroPython,Rust | | 5 | Eve | HTML,CSS,Python | Expected result: | user_id | name | skills | |---|---|---| | 1 | Alice | Java,Python,SQL | | 3 | Carol | Python | | 5 | Eve | HTML,CSS,Python | Alice has `Python` in the middle of her list, Carol has it as her only skill, and Eve has it last. Bob has no Python skill, and Dave's `MicroPython` only contains the text, so neither matches. ### Constraints and Clarifications - There are 1 to 10,000 users. - Skill names are alphanumeric, separated by commas with no spaces. - `skills` may be NULL or an empty string. Such users never match. - Skill names use consistent capitalization, so the skill always appears as `Python` and an exact, case-sensitive match is correct. - `user_id` is unique, so each matching user appears once in the output.

Overview: Write a SQL query that finds users whose comma-separated skills string contains Python as a complete skill, without matching names such as MicroPython or Python3. It tests token matching with anchored regular expressions or string splitting, along with NULL and empty-string handling.

LinkedIn logo
LinkedIn
Nov 24, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

UserProfile stores each user's skills as one comma-separated string, for example 'Java,Python,SQL'.

Find the users whose skills include Python as a complete skill. Substrings like MicroPython or Python3 must not match. Return user_id, name and skills, ordered by user_id ascending.

Input Table(s)

UserProfile

ColumnTypeMeaning
user_idINTThe user
nameVARCHAR(100)The user's name
skillsVARCHAR(500)Comma-separated skill names, may be NULL or empty

Primary key: user_id.

Output Contract

ColumnMeaning
user_idThe matching user
nameThe user's name
skillsThe original skills string, unchanged

Return one row per matching user, ordered by user_id ascending.

Example

UserProfile

user_idnameskills
1AliceJava,Python,SQL
2BobC++,Go
3CarolPython
4DaveMicroPython,Rust
5EveHTML,CSS,Python

Expected result:

user_idnameskills
1AliceJava,Python,SQL
3CarolPython
5EveHTML,CSS,Python

Alice has Python in the middle of her list, Carol has it as her only skill, and Eve has it last. Bob has no Python skill, and Dave's MicroPython only contains the text, so neither matches.

Constraints and Clarifications

  • There are 1 to 10,000 users.
  • Skill names are alphanumeric, separated by commas with no spaces.
  • skills may be NULL or an empty string. Such users never match.
  • Skill names use consistent capitalization, so the skill always appears as Python and an exact, case-sensitive match is correct.
  • user_id is unique, so each matching user appears once in the output.