这是基本的,如果我错过了现有的答案,我深表歉意。我正在尝试在数据库中选择userid
与我提供的数组中的任何字符串匹配的行。以下是我尝试过的方法:
query_string = "SELECT * FROM data WHERE userid = ANY([qFupLOnc1,bUVMBxum0,FlYYzQz31]) LIMIT 5"
query_string = "SELECT * FROM data WHERE userid = ANY(['qFupLOnc1','b2VMBxum0','FlYYzQz31']) LIMIT 5"
query_string = "SELECT * FROM data WHERE userid = ANY(ARRAY['qFupLOnc1','bUVMBxum0','FlYYzQz31']) LIMIT 5"
query_string = "SELECT * FROM data WHERE userid = ANY(ARRAY[qFupLOnc1,bUVMBxum0,FlYYzQz31]) LIMIT 5"
query_string = "SELECT * FROM data WHERE userid ANY(ARRAY[qFupLOnc1,bUVMBxum0,FlYYzQz31]) LIMIT 5"
query_string = "SELECT * FROM data WHERE userid ANY(ARRAY['qFupLOnc1','bUVMBxum0','FlYYzQz31']) LIMIT 5"
query_string = "SELECT * FROM data WHERE userid ANY(['qFupLOnc1','bUVMBxum0','FlYYzQz31']) LIMIT 5"
query_string = "SELECT * FROM data WHERE userid ANY([qFupLIOnc1,bU2VMBxum0,FlYYzQz31]) LIMIT 5"
这些都返回错误。这样做的正确方法是什么?
我正在通过 R 包查询数据库,RPostgreSQL
如下所示:
data = dbGetQuery(con, query_string)