SQLite query with two WHERE clauses

I’m trying to do a query on my local sqlite db where I use two WHERE clauses:

    db.transaction((tx) => {
      tx.executeSql('SELECT * FROM dr_template_relational WHERE subcategory_id = (?) AND template_id = (?)', [530, 480],
      (trans, result) => {

This is what I’ve tried but it doesn’t work. The code has to be dynamic so values will change that’s why I just don’t hard code it in and input the value in the string.

I know I can do it with concatenation like this:
tx.executeSql('SELECT * FROM dr_template_relational WHERE subcategory_id = ' + subCatId + ' AND template_id = ' + this.state.currentTemplateId, [],

But I wanted to see if I can do it like the first example. Any ideas how I can do this?

It’s been a while, but off the top of my head, maybe you want to omit the parenthesis?

One common misconception about the Expo SQLite library is that it is some kind of SQLite API customized just for Expo. It’s not. It’s effectively the same API as vanilla React Native, Cordova, WebSQL, Node, etc. And it’s even pretty similar to native Swift and Java implementations, as all of these platform-specific SQLite libraries are thin wrappers over the C SQLite API that ships with every phone. So, while I wouldn’t want to discourage anyone from asking a question- especially in the catch-all “How To” section- you (and others- these questions come up a lot) might have better luck with general SQLite questions in a forum that attracts a lot of SQLite developers across platforms (like StackOverflow). Here’s we’re squarely focused on React Native and Expo, with only a small percentage of us (I assume) working regularly with SQLite.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.