當我嘗試查找details
表中存在Linux
列的所有記錄時,該列中存在數組列operating_systems
。如何在Postgresql查詢中處理單引號
查詢select * from details where 'Linux' = ANY(operating_systems);
完美工作,並返回operating_systems
列中有Linux
的所有記錄。
但是,如果我想獲得I don't know
存在於operating_systems
中的所有記錄,我無法形成正確的查詢。
查詢select * from details where 'I don\'t know' = ANY(operating_systems);
不會逃避單引號並將其從字面上取出,從而導致不完整的查詢。
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS –