我正在使用RODBC
包进行简单的MYSQL查询:
loadData_pd <- function(namesurname) {
lapply( dbListConnections( dbDriver( drv = "MySQL")), dbDisconnect)
# Connect to the database
db <- dbConnect(MySQL(), dbname = 'database_name', host = options()$mysql$host,
port = options()$mysql$port, user = options()$mysql$user,
password = options()$mysql$password)
# Construct the fetching query
query <- sprintf("SELECT * FROM pd_fizicke WHERE imeprezime = '%s'",
namesurname)
# Submit the fetch query and disconnect
data <- dbGetQuery(db, query)
dbDisconnect(db)
data
}
我想更改查询以包含模糊搜索。更具体地说,如果一个角色存在差异,它应该返回一行(&#34; John&#34;&#34; Jehn&#34;两者都包括在内)。所以Levenstein的距离应该是一个。如果名字和姓氏的顺序不同,我也希望它返回结果(&#34; John Williams&#34;&#34; Williams John&#34;都可以)。我该如何更改查询以获得上述结果?