Complete the code to check if the JSONB column 'data' contains the key 'name'.
SELECT * FROM users WHERE data [1] 'name';
The ? operator checks if the JSONB column contains the specified key.
Complete the code to find rows where the JSONB column 'info' contains the key 'age'.
SELECT id FROM profiles WHERE info [1] 'age';
The ? operator checks for a single key's existence in JSONB.
Fix the error in the code to check if the JSONB column 'attributes' contains the key 'color'.
SELECT * FROM items WHERE attributes [1] 'color';
The correct operator to check key existence is ?. Others extract or compare JSONB data differently.
Complete the code to check if the JSONB column 'settings' contains both keys 'dark_mode' and 'notifications'.
SELECT * FROM user_prefs WHERE settings [1] ARRAY['dark_mode', 'notifications'] ;
The ?& operator checks if all keys in the array exist in the JSONB column. No extra symbol is needed after the operator.
Fill both blanks to find rows where the JSONB column 'config' contains either 'auto_save' or 'backup' keys.
SELECT * FROM documents WHERE config [1] ARRAY['auto_save', [2]] ;
The ?| operator checks if any key in the array exists in the JSONB column. The keys must be quoted strings. No extra symbol is needed after the operator.