请解释我如何为这样的代码编写LIKE
运算符?我在下面编写了代码,但它似乎不适用于 FMDB 。
func getsearchStudentData(word:String) -> NSMutableArray {
sharedinstance.database!.open()
let resultSet: FMResultSet! = sharedinstance.database!.executeQuery("SELECT * FROM student_info WHERE name LIKE '%?' ", withArgumentsInArray: [word])
let sarrStudentInfo : NSMutableArray = NSMutableArray()
if (resultSet != nil) {
while resultSet.next() {
let studentInfo : student_info = student_info()
studentInfo.RollNo = resultSet.stringForColumn("RollNo")
studentInfo.Name = resultSet.stringForColumn("Name")
studentInfo.Marks = resultSet.stringForColumn("Mark")
sarrStudentInfo.addObject(studentInfo)
}
}
sharedinstance.database!.close()
return sarrStudentInfo }
答案 0 :(得分:-2)
swift 3
试试这个
let query = "select \(field_ImageID) from \(imageTag_tableName) where \(field_ImageTag) LIKE ?;"
...
let results = try database.executeQuery(query, values: ["%\(tag)%"])