I’m a newbie to the use of SQL and databases; my apps have stayed pretty local thus far. However, I have a database that populates the table in my app, nothing overly complicated.
I want to incorporate a favorites menu. The way I approached this was by creating a column in the SQL database titled Favorite, and then checking to see if the value is 0 (not favorited) or 1 (favorited). Now, how would one go through all the rows in the SQL database, checking to see if they are favorited, and then printing them to the table?
I’m going to write some phonetic code to give a better idea of what I’m going for:
var rows = db.execute('SELECT DISTINCT entity_name FROM entity_info');
while (rows.isValidRow()) {
if (FavoritesValue FROM db == 1) {
//This line here is what I need ^^^ The syntax is not right, its an example.
var row = Ti.UI.createTableViewRow({
title:rows.fieldByName('entity_name')
});
}
rows.next();
}
I marked the line that I need help with in the code.
I wouldn’t return data you don’t need. Just make your condition part of the SQL statment:
Change
To