MulaiMulai sekarang secara gratis

Searching an ARRAY with ANY

As we saw in the video, PostgreSQL also provides the ability to filter results by searching for values in an ARRAY. The ANY function allows you to search for a value in any index position of an ARRAY. Here's an example.

WHERE 'search text' = ANY(array_name)

When using the ANY function, the value you are filtering on appears on the left side of the equation with the name of the ARRAY column as the parameter in the ANY function.

Latihan ini adalah bagian dari kursus

Functions for Manipulating Data in PostgreSQL

Lihat Kursus

Petunjuk latihan

  • Match 'Trailers' in any index of the special_features ARRAY regardless of position.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

SELECT
  title, 
  special_features 
FROM film 
-- Modify the query to use the ANY function 
WHERE ___ = ___ (___);
Edit dan Jalankan Kode