Thanks To Visit: Most Welcome
Thanks To Visit: Most Welcome
Thanks To Visit: Most Welcome
Most Welcome
SPT999
Create database mydatabase;
Show databases;
use mydatabase;
Show tables;
Desc mytable;
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
ORDER BY column_name(s);
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);
1: Query to print number of employees in particular city.
2: Query to print number of employees in particular city that are less than 3
3: Query to print name and city of employees in particular city that are less
than 3
4: write a query to find out maximum salary of a city that will be accumulate
by addition of salary of employees group by city.
select city,count(city) from employee group by
city having count(city)<3;
select first_name,city from employee where city in (select city from employee
group by city having count(city)<3);
Write a query to find out records which have post clerk and city Kanpur.
Write a query to find out records which have post clerk or city Kanpur.
Date DATEDIFF
datetime expression
Returns the number of days between
Functions DATE_ADD
two date values
Adds a time/date interval to a date
and then returns the date
DATE_FORMAT Formats a date
DATE_SUB Subtracts a time/date interval from a
date and then returns the date
DAY Returns the day of the month for a
given date
DAYNAME Returns the weekday name for a
given date
DAYOFMONTH Returns the day of the month for a
given date
DAYOFWEEK Returns the weekday index for a
given date
DAYOFYEAR Returns the day of the year for a
given date
SELECT column_name(s)
FROM table_name
WHERE condition
LIMIT number;
Select curdate();
Select current_date();
Select sysdate();
Select now();
select curtime();
create table new2(name varchar(20),dob date,tob time,dtob datetime);
select year(curdate())-year(dob)-2022,month(curdate())-
month(dob),day(curdate())-day(dob) from new2;
select datediff(curdate(),dob)/365 as
year,mod(datediff(curdate(),dob),365)/30 as month,
mod(mod(datediff(curdate(),dob),365)/30,30) as day from new2;
Natural Join.
Self Join.
Inner join
Left
Right
cross
Natural Join
Select P1.RollN , P1.Project from Project P1,Project P2 where p1.RollN=p2.RollN and p1.PrN<>p2.PrN
Left Join
select * from student left join project on
student.RollN=project.RollN;
Right Join
select * from student right join project on
student.RollN=project.RollN;
The CROSS JOIN keyword returns all matching records from
both tables whether the other table matches or not.
So, if there are rows in "Customers" that do not have matches in
"Orders", or if there are rows in "Orders" that do not have matches in
"Customers", those rows will be listed as well.
If you add a WHERE clause (if table1 and table2 has a relationship),
the CROSS JOIN will produce the same result as the INNER JOIN clause:
CREATE VIEW view_name AS Note: A view always shows up-to-date
SELECT column1, column2, data! The database engine recreates the
FROM table_name view, every time a user queries it.
WHERE condition;
Foreign key is not the primary key of same table.. Then we can set it null
School Management
vikasspatel9@gmail.com