Mysql Quries
Mysql Quries
2) select name , age, city from data table name where city=’Hyderabad”;
6) select distinct city from students; (unic or not repeat again some city name so use distinct);
7) select count(distinct city) from student; (unic or non repeat citys if 25citys there will come number
25)
9) select * from student limit 0,10 (how many records we want count only not 20 number still)
10)select id ,name,age,city from student order by id desc limit 0,1; (desinding order (last))
14) select sum(age) from students;(if we want total soming in data table we do sum operation)
16) select gender,count(id) from student group by gender; out put female=10,male=22
17)select city ,count(id) from students group by city;out put e city lo entha mandhi student vunnaro
total number esthudhi 22 or 25like
18)select name from students where name like “pa%”(pa tho start ayyename and pa tharavath em
vunna data fech avuthundhi)
19) select name from students where name like”%am”; (finishing lo am vunte display avuthundhi)
20) select name from student where name like “%am%”(midile lo amvunte vasthundhi)
22) select * from students where city in(“hyd”,”wanaparhty”);( both city students will come)
23) select * from students where city not in(“hyd”,”wanaparhty”); (remaining city out put willcome )
24) select name from students where name not like “ra%”; (remaining city out put willcome )
25) select name, age from students where age between 24 and 30;(here also we usenot like)
26) select * from students where id=2; (we will get id 2 person details)
27) select id,count(adate) as working , count(if (astatus=”p”,null)) as present from attendance group by
id;
Output:
Id working present
1 4 3
2 4 2
3 4 4
28) select count (distinct city) as total from students;(total citys count number will get 6 or 8like)
29)
Find all name like start name with R and last name should be d
Sql :
SELECT username, first_name, last_name, email FROM auth_user WHERE first_name LIKE 'R%, OR
last_name LIKE 'D%';
Django:
union:
The UNION operator is used to combine the result-set of two or more querysets. The querysets can be
from the same or from different models. When they querysets are from different models, the fields and
their datatypes should match.