views:

85

answers:

1

How to construct sqlite query containing ampersand in filter:

SELECT id FROM mediainfo WHERE album="Betty & Kate";

I use sqlite C interface (sqlite3_bind_text() and ? marks while query building) but neither C query nor SQLite Administrator return any data

A: 

& is not a special character either in C strings or in SQL strings, so I don't think that's the problem. Try the same query from a tool like SQLite Database Browser.

Evgeny
As I said, I've tried the query in SQLite Administrator: http://sqliteadmin.orbmu2k.de/ . I don't think SQLite Database Browsert is any different. It seems like I should escape the ampersand sign somehow in the query
Denis Gorodetskiy
BTW, SELECT id FROM mediainfo WHERE album LIKE 'Betty works but it's not exactly what I want.
Denis Gorodetskiy
Again, <SELECT id FROM mediainfo WHERE album='Betty % Kate'> works too but % is a wildcard character and I want exact match
Denis Gorodetskiy
Well, that *is* weird! I would create another 2 rows (using your SQLite Administrator), with and without an ampersand, but otherwise the same and test it with that, just to confirm that the ampersand is the problem.
Evgeny
Sorry my bad. I've mistakenly interchanged "album" column name with "artist"..But now, got another problem: how to escape single quote character?
Denis Gorodetskiy
album name is <80's Giga Hits Collection>, don't know how to filter all songs with this album
Denis Gorodetskiy
to escape it, I had to use two single quotes
Denis Gorodetskiy