Get Started

Searching an ARRAY with @>

The contains operator @> operator is alternative syntax to the ANY function and matches data in an ARRAY using the following syntax.

WHERE array_name @> ARRAY['search text'] :: type[]

So let's practice using this operator in the exercise.

This is a part of the course

“Functions for Manipulating Data in PostgreSQL”

View Course

Exercise instructions

  • Use the contains operator to match the text Deleted Scenes in the special_features column.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

SELECT 
  title, 
  special_features 
FROM film 
-- Filter where special_features contains 'Deleted Scenes'
WHERE ___ ___ ARRAY['Deleted Scenes'];

This exercise is part of the course

Functions for Manipulating Data in PostgreSQL

IntermediateSkill Level
4.5+
47 reviews

Learn the most important PostgreSQL functions for manipulating, processing, and transforming data.

Learn about the properties and characteristics of common data types including strings, numerics and arrays and how to retrieve information about your database.

Exercise 1: Welcome!Exercise 2: Text data typesExercise 3: Getting information about your databaseExercise 4: Determining data typesExercise 5: Date and time data typesExercise 6: Properties of date and time data typesExercise 7: Interval data typesExercise 8: Working with ARRAYsExercise 9: Accessing data in an ARRAYExercise 10: Searching an ARRAY with ANYExercise 11: Searching an ARRAY with @>

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free