I want to receive info from 2 columns with OR operator, but i can not visualice.
I have my column title and my column categoria. I want to make a select that affects both columns, something like this: selec * from title OR categoria where ...
this is what i have:
final List<Map<String, dynamic>> queryResult = await db
.rawQuery('SELECT * FROM todos WHERE title like ?', ['%'+queryCourse+'%']); //here i want to complete the select with both columns
>Solution :
Use the OR operator for the 2 columns:
final List<Map<String, dynamic>> queryResult = await db
.rawQuery('SELECT * FROM todos WHERE title LIKE ? OR categoria LIKE ?',
['%'+queryCourse+'%', '%'+queryCourse+'%']);
or:
final List<Map<String, dynamic>> queryResult = await db
.rawQuery("SELECT * FROM todos WHERE title LIKE '%' || ? || '%' OR categoria LIKE '%' || ? || '%'",
[queryCourse, queryCourse]);
I assumed that for both columns you will use the same parameter queryCourse.
If not, then change the parameters with the ones you have.