vendredi 24 avril 2015

SQL/python joining wildcards with variables

I have a variable being passed in a function that is called usernick.

Im trying to query my database for all cases of which a particular field contains the wild card character @ followed by the variable usernick

This is what I have so far and its not bringing back the correct results

sql = "SELECT * FROM posts WHERE content LIKE '%@' + (?) + '%' "
    return list(cursor.execute(sql,(usernick, )))

Any suggestions? :)

Aucun commentaire:

Enregistrer un commentaire