Untitled
unknown
plain_text
2 years ago
2.1 kB
20
Indexable
Order by clause:
order by is used to sot the data in the assending or descending order.
syntax:- selct * from tablename order by column_name asc/desc
select * from Orders order by item asc;
when we short data in any filter condition we use where and order by clause;
sequence is mandatory:
1 where
2.order by
example:
select * from Orders where customer_id=4 order by item desc ;
----------------------------------------------------------------------------------------
Update staement:
update staement is use for modify the existing records.
ex:-update Orders set item="keypad" where order_id=4;
modify multiple colums:
ex:update Orders set item="keyboard" ,customer_id=5 where order_id=4;
exmple : modify columns in multiple values
update Orders set customer_id=5 where order_id in (2,3) ;
update Orders set customer_id=3 where order_id =2 or item="Keyboard";
update Orders set customer_id=3 where order_id =2 and item="Keyboard";
-------------------------------------------------------------------------------------
difference between update and alter:
alter:1. data defination lang(DDL)
2.alter command will perform structure level.
3.syntax alter table tablename (modify/add/rename) Drop column column_name
update:1. data manipulation lang(DML)
2.update command will perform on data level.
3 syntax :-update table_name set column_name=values
---------------------------------------------------------------------------------------------
group by :
it is used for grouping data in given column.
group by is used with agreegate function (sum(), count(), avg(),min(),max().
syntax:
select column_name() from table_name group by column_name;
ex:-select count(*) as count,country from Customers group by country;
select count(*) as count,country from Customers group by country order by country desc;
sequence:- where
group by
order by
group by with where statement
select count(*) as count,country from Customers where customer_id in (2,4) group by country order by country desc;
Editor is loading...
Leave a Comment