Без использования подзапроса я бы хотел найти, если все элементы в массиве равны подмножеству чисел. Итак, вместо 1 = ALL(ARRAY[1,1,1])
Я хочу сделать что-то вроде ALL(ARRAY[1,1,1]) IN (1, 5)
. Возможно ли это без использования оператора select?Postgresql ALL with IN
1
A
ответ
0
Вы хотите использовать оператор @>
.
-- does the column contain all of
select * from test_arrays where values @> array[6, 9];
select * from test_arrays where values @> '{6, 9}'::int[];
Если вы хотите, чтобы найти где-либо 1 значение массива в другой массив использовать &&
оператор:
-- does the column contain at-least one of
select * from test_arrays where values && array[6, 9];
select * from test_arrays where values && '{6, 9}'::int[];
мне довелось написать об этом пару месяцев назад.
http://www.philliphaydon.com/2016/05/07/postgresql-and-its-array-datatype/
Смежные вопросы
- 1. Tree view with check all or uncheck all in knockout.js
- 2. Check All/Uncheck All with jquery
- 3. 'select all' and 'remove all' with selected.js
- 4. Promise .all() with RxJS
- 5. UNION ALL in CTE
- 6. SQL ALL IN статья
- 7. Regex match all with delimiter
- 8. listbox with checkbox, with select All option
- 9. Использование IN с ALL
- 10. PostgreSQL regexp.replace all unwanted chars
- 11. Link All Views With Prefix
- 12. MongoDB: $ all with empty array ...
- 13. Convert all canvas with toDataURL()
- 14. check all checkbox with hide
- 15. UIKeyInput with All Caps Keyboard
- 16. SELECT ALL with SUM (Col)
- 17. Check All Checkbox with Pagination
- 18. Laravel Eloquent - Where In All
- 19. Postgresql Query with joins
- 20. OverflowException with dotConnection PostgreSQL
- 21. IF in WITH structure
- 22. SQL select statement union all with itself
- 23. return all IQueryable with Entity framework
- 24. WITH ... UPDATE в PostgresQL
- 25. jqgrid pagination with postgresql
- 26. PostgreSQL: mkdir with plpgsql
- 27. Rancher with postgresql
- 28. Postgresql with golang, вопросы
- 29. Postgresql join with limit
- 30. Count Distinct with PostgreSQL