SQL Important queries


Fetch record in ASC or DESC order 


//DECENDING ORDER
SELECT * FROM mytablename ORDER BY id DESC 

//ASSENDING ORDER
SELECT * FROM mytablename ORDER BY id ASC

//WITH LIMIT 
SELECT * FROM mytablename ORDER BY id DESC LIMIT 50


How to fetch last 50 records from table

SELECT * FROM ( SELECT * FROM mytablename ORDER BY id DESC LIMIT 50 )sub ORDER BY id ASC 

Update column fields using update commands 

UPDATE tablename SET devicemodel='Data what you want to replace' where devicemodel='HUAWEI G730-U00' 



Use Delete commands 

DELETE FROM Persons WHERE FirstName = 'Peter'



Comments

Popular posts from this blog

Bluetooth Data Transfer Example

DeCompile .apk file on ubuntu 14.04