Tuesday, December 15, 2009

iPhone dev Stupidity 114: Muliti column order

1. to order by two columns

From here

SELECT * FROM Individual
ORDER BY FirstName, LastName

2. We want to sort files by name - when two files have the same name we sort them by the date time:

NSString * sql = [NSString stringWithFormat: @"SELECT arts.*, tags.name FROM arts, tags WHERE category_id = %d and arts.tag_1 = tags.tag_id and ((tags.name = '%@' and arts.date_touched > '%@') or tags.name > '%@') ORDER BY tags.name LIMIT 1", cur_art.category_id_, cur_name, cur_art.date_touched_, cur_name];



No comments: