Q: swift sqlite count+where always reutrns 0 i have problems using SQlite for Swift with COUNT and WHERE.
My Code:
let stmtString = "SELECT COUNT(*) FROM Items WHERE codestring LIKE '%\(code)%'"    
let stmt = try self.connection?.prepare("\(stmtString)")

if let stmt = stmt {
    for row in stmt {
        print(row)
    }
}

the result contains 1 value(as it should) but it is 0.
Both SELECT COUNT(*) FROM Items" and "SELECT * FROM Items WHERE codestring LIKE '%\(code)%'" work as they should, but i don't want to calculate it in my code in hopes of better performance. What am i doing wrong?

A: So, the item existed in the table doesn't confirm the rule you wrote:
codestring LIKE '%\(code)%' check it more carefully
Simple "SELECT * FROM Items should work.

A: You should use scalar instead of prepare for aggregate functions see the doc
let stmt = try self.connection?.scalar("\(stmtString)")

