Tuesday, 15 December 2015

SQLite Queries

12:07:00 Posted by Kumanan
1. To Get all datas:-
    SELECT * FROM TABLE_NAME

2. To get single item against userId:-
   SELECT * FROM TABLE_NAME WHERE COLUMN_NAME LIKE '%item_id%'


3. Sorting:-
      SELECT * FROM TABLE_NAME  ORDER BY  COLUMN_NAME COLLATE NOCASE ASC
      But you don't need the ASC -- that's the default so you could just as well use:
SELECT * FROM TABLE_NAME  ORDER BY  COLUMN_NAME COLLATE NOCASE

4. Get Last Entry from a Table:-
      SELECT * FROM TABLE_NAME ORDER BY COLUMN_NAME DESC LIMT 1

5. Delete a row:-
     DELETE FROM TABLE_NAME WHERE COLUMN_NAME LIKE '%id%'

6. Delete a table:-
     DROP TABLE TABLE_NAME