-2

I have table from which i want that it should fetch data by desc views but where cluase using here is the query it does not return any thing.

                 select = [[NSString alloc] initWithFormat:@"select * FROM ContentMaster WHERE ContentTagText ORDER BY Views DESC ='%@'",appDelegate.tagInput];

If remove where clause then it shows data in desc.

4

1 回答 1

1

you need to restructure your query, you mixed up the ORDER BY and WHERE clauses. It should look something like this:

NSString *select = [NSString stringWithFormat:@"SELECT * FROM ContentMaster WHERE ContentTagText = '%@' ORDER BY Views", appDelegate.tagInput];

I don't know the exact names of your columns, so you might need to adjust that. But basically the filter (= '%@') needs to be in the WHERE clause, the ORDER BY clause contains the column by which the result is sorted.

于 2013-11-05T07:08:51.583 回答