0% found this document useful (0 votes)
17 views16 pages

Mysql Revision

Uploaded by

sarneetkaur06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views16 pages

Mysql Revision

Uploaded by

sarneetkaur06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 16

mysql> show databases;

+--------------------+
| Database |
+--------------------+
| company |
| guggu |
| hui |
| info |
| infopract |
| information_schema |
| ipttn |
| jmj |
| kappa |
| mysql |
| office |
| office2 |
| performance_schema |
| sani |
| sarneet |
| savi |
| school |
| school55 |
| sys |
| tution |
| vanshika |
| yuvraj |
+--------------------+
22 rows in set (0.04 sec)

mysql> use school;


Database changed
mysql> show tables;
+------------------+
| Tables_in_school |
+------------------+
| s |
| students |
+------------------+
2 rows in set (0.01 sec)

mysql> select * from s;


+----------+----------+-------+---------+-------+---------------------------
+--------+------------+
| admin_no | name | class | subject | marks | e_id |
marks2 | DOB |
+----------+----------+-------+---------+-------+---------------------------
+--------+------------+
| 723 | Sarneet | 12 | IP | 100 | [email protected] | 50
| 2006-10-06 |
| 724 | Savitri | 12 | Maths | 100 | [email protected] | 49
| 2007-11-20 |
| 732 | Yuvraj | 12 | Maths | 98 | [email protected] | 45
| 2007-03-12 |
| 733 | Dwij | 12 | Maths | 97 | [email protected] | 42
| 2007-08-03 |
| 736 | Dhruv | 12 | IP | 74 | [email protected] | 41
| 2007-02-14 |
| 740 | Kangna | 12 | maths | 51 | [email protected] | 20
| 2007-11-24 |
| 763 | Vanshika | 12 | IP | 85 | [email protected] | 40
| 2007-09-08 |
| 795 | Ashish | 12 | maths | 82 | [email protected] | 39
| 2007-06-10 |
+----------+----------+-------+---------+-------+---------------------------
+--------+------------+
8 rows in set (0.02 sec)

mysql> update s set marks=50 where name='savitri';


Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from s;


+----------+----------+-------+---------+-------+---------------------------
+--------+------------+
| admin_no | name | class | subject | marks | e_id |
marks2 | DOB |
+----------+----------+-------+---------+-------+---------------------------
+--------+------------+
| 723 | Sarneet | 12 | IP | 100 | [email protected] | 50
| 2006-10-06 |
| 724 | Savitri | 12 | Maths | 50 | [email protected] | 49
| 2007-11-20 |
| 732 | Yuvraj | 12 | Maths | 98 | [email protected] | 45
| 2007-03-12 |
| 733 | Dwij | 12 | Maths | 97 | [email protected] | 42
| 2007-08-03 |
| 736 | Dhruv | 12 | IP | 74 | [email protected] | 41
| 2007-02-14 |
| 740 | Kangna | 12 | maths | 51 | [email protected] | 20
| 2007-11-24 |
| 763 | Vanshika | 12 | IP | 85 | [email protected] | 40
| 2007-09-08 |
| 795 | Ashish | 12 | maths | 82 | [email protected] | 39
| 2007-06-10 |
+----------+----------+-------+---------+-------+---------------------------
+--------+------------+
8 rows in set (0.00 sec)

mysql> update s set marks=100 where name='savitri';


Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update s set marks2=50 where name='savitri';


Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> alter table s add fees int;


Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> update s set fees=50000 where name='sarneet';


Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update s set fees=50000 where name='savitri';


Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update s set fees=45000 where name='yuvraj';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update s set fees=45000 where name='dwij';


Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update s set fees=44000 where name='dhruv';


Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update s set fees=49000 where name='vanshika';


Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from s;


+----------+----------+-------+---------+-------+---------------------------
+--------+------------+-------+
| admin_no | name | class | subject | marks | e_id |
marks2 | DOB | fees |
+----------+----------+-------+---------+-------+---------------------------
+--------+------------+-------+
| 723 | Sarneet | 12 | IP | 100 | [email protected] | 50
| 2006-10-06 | 50000 |
| 724 | Savitri | 12 | Maths | 100 | [email protected] | 50
| 2007-11-20 | 50000 |
| 732 | Yuvraj | 12 | Maths | 98 | [email protected] | 45
| 2007-03-12 | 45000 |
| 733 | Dwij | 12 | Maths | 97 | [email protected] | 42
| 2007-08-03 | 45000 |
| 736 | Dhruv | 12 | IP | 74 | [email protected] | 41
| 2007-02-14 | 44000 |
| 740 | Kangna | 12 | maths | 51 | [email protected] | 20
| 2007-11-24 | NULL |
| 763 | Vanshika | 12 | IP | 85 | [email protected] | 40
| 2007-09-08 | 49000 |
| 795 | Ashish | 12 | maths | 82 | [email protected] | 39
| 2007-06-10 | NULL |
+----------+----------+-------+---------+-------+---------------------------
+--------+------------+-------+
8 rows in set (0.00 sec)

mysql> select name,fees from s where fees>=43000;


+----------+-------+
| name | fees |
+----------+-------+
| Sarneet | 50000 |
| Savitri | 50000 |
| Yuvraj | 45000 |
| Dwij | 45000 |
| Dhruv | 44000 |
| Vanshika | 49000 |
+----------+-------+
6 rows in set (0.00 sec)

mysql> select name,fees from s where fees>=49000;


+----------+-------+
| name | fees |
+----------+-------+
| Sarneet | 50000 |
| Savitri | 50000 |
| Vanshika | 49000 |
+----------+-------+
3 rows in set (0.00 sec)

mysql> select name,fees from s where fees>49000;


+---------+-------+
| name | fees |
+---------+-------+
| Sarneet | 50000 |
| Savitri | 50000 |
+---------+-------+
2 rows in set (0.00 sec)

mysql> select name,fees from s where fees<=49000;


+----------+-------+
| name | fees |
+----------+-------+
| Yuvraj | 45000 |
| Dwij | 45000 |
| Dhruv | 44000 |
| Vanshika | 49000 |
+----------+-------+
4 rows in set (0.00 sec)

mysql> select name,fees from s where fees<49000;


+--------+-------+
| name | fees |
+--------+-------+
| Yuvraj | 45000 |
| Dwij | 45000 |
| Dhruv | 44000 |
+--------+-------+
3 rows in set (0.00 sec)

mysql> select name,fees from s where fees=49000;


+----------+-------+
| name | fees |
+----------+-------+
| Vanshika | 49000 |
+----------+-------+
1 row in set (0.00 sec)

mysql> select sum(fees), name from s;


ERROR 1140 (42000): In aggregated query without GROUP BY, expression #2 of SELECT
list contains nonaggregated column 'school.s.name'; this is incompatible with
sql_mode=only_full_group_by
mysql> select sum(fees) from s;
+-----------+
| sum(fees) |
+-----------+
| 283000 |
+-----------+
1 row in set (0.01 sec)

mysql> select name ,sum(fees) from s;


ERROR 1140 (42000): In aggregated query without GROUP BY, expression #1 of SELECT
list contains nonaggregated column 'school.s.name'; this is incompatible with
sql_mode=only_full_group_by
mysql> select sum(fees) from s;
+-----------+
| sum(fees) |
+-----------+
| 283000 |
+-----------+
1 row in set (0.00 sec)

mysql> select min(fees) from s;


+-----------+
| min(fees) |
+-----------+
| 44000 |
+-----------+
1 row in set (0.01 sec)

mysql> select max(fees) from s;


+-----------+
| max(fees) |
+-----------+
| 50000 |
+-----------+
1 row in set (0.00 sec)

mysql> select len(fees) from s;


ERROR 1305 (42000): FUNCTION school.len does not exist
mysql> select avg(fees) from s;
+------------+
| avg(fees) |
+------------+
| 47166.6667 |
+------------+
1 row in set (0.01 sec)

mysql> select count(fees) from s;


+-------------+
| count(fees) |
+-------------+
| 6 |
+-------------+
1 row in set (0.01 sec)

mysql> select sum(fees) from s where admin_no>=755;


+-----------+
| sum(fees) |
+-----------+
| 49000 |
+-----------+
1 row in set (0.01 sec)

mysql> select sum(fees) from s where admin_no>=732;


+-----------+
| sum(fees) |
+-----------+
| 183000 |
+-----------+
1 row in set (0.00 sec)
mysql> select min(fees) from s where admin_no>=732;
+-----------+
| min(fees) |
+-----------+
| 44000 |
+-----------+
1 row in set (0.00 sec)

mysql> select max(fees) from s where admin_no>=732;


+-----------+
| max(fees) |
+-----------+
| 49000 |
+-----------+
1 row in set (0.00 sec)

mysql> select avg(fees) from s where admin_no>=732;


+------------+
| avg(fees) |
+------------+
| 45750.0000 |
+------------+
1 row in set (0.00 sec)

mysql> select count(fees) from s where admin_no>=732;


+-------------+
| count(fees) |
+-------------+
| 4 |
+-------------+
1 row in set (0.00 sec)

mysql> desc s;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| admin_no | int | NO | PRI | NULL | |
| name | varchar(20) | YES | | NULL | |
| class | int | YES | | NULL | |
| subject | varchar(10) | YES | | NULL | |
| marks | int | YES | | NULL | |
| e_id | varchar(30) | YES | | NULL | |
| marks2 | char(2) | YES | | NULL | |
| DOB | date | YES | | NULL | |
| fees | int | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
9 rows in set (0.01 sec)

mysql> select * from s where name like"s%";


+----------+---------+-------+---------+-------+--------------------------+--------
+------------+-------+
| admin_no | name | class | subject | marks | e_id | marks2
| DOB | fees |
+----------+---------+-------+---------+-------+--------------------------+--------
+------------+-------+
| 723 | Sarneet | 12 | IP | 100 | [email protected] | 50
| 2006-10-06 | 50000 |
| 724 | Savitri | 12 | Maths | 100 | [email protected] | 50
| 2007-11-20 | 50000 |
+----------+---------+-------+---------+-------+--------------------------+--------
+------------+-------+
2 rows in set (0.00 sec)

mysql> select * from s where name like"%s%";


+----------+----------+-------+---------+-------+---------------------------
+--------+------------+-------+
| admin_no | name | class | subject | marks | e_id |
marks2 | DOB | fees |
+----------+----------+-------+---------+-------+---------------------------
+--------+------------+-------+
| 723 | Sarneet | 12 | IP | 100 | [email protected] | 50
| 2006-10-06 | 50000 |
| 724 | Savitri | 12 | Maths | 100 | [email protected] | 50
| 2007-11-20 | 50000 |
| 763 | Vanshika | 12 | IP | 85 | [email protected] | 40
| 2007-09-08 | 49000 |
| 795 | Ashish | 12 | maths | 82 | [email protected] | 39
| 2007-06-10 | NULL |
+----------+----------+-------+---------+-------+---------------------------
+--------+------------+-------+
4 rows in set (0.00 sec)

mysql> select * from s where name like"%a%";


+----------+----------+-------+---------+-------+---------------------------
+--------+------------+-------+
| admin_no | name | class | subject | marks | e_id |
marks2 | DOB | fees |
+----------+----------+-------+---------+-------+---------------------------
+--------+------------+-------+
| 723 | Sarneet | 12 | IP | 100 | [email protected] | 50
| 2006-10-06 | 50000 |
| 724 | Savitri | 12 | Maths | 100 | [email protected] | 50
| 2007-11-20 | 50000 |
| 732 | Yuvraj | 12 | Maths | 98 | [email protected] | 45
| 2007-03-12 | 45000 |
| 740 | Kangna | 12 | maths | 51 | [email protected] | 20
| 2007-11-24 | NULL |
| 763 | Vanshika | 12 | IP | 85 | [email protected] | 40
| 2007-09-08 | 49000 |
| 795 | Ashish | 12 | maths | 82 | [email protected] | 39
| 2007-06-10 | NULL |
+----------+----------+-------+---------+-------+---------------------------
+--------+------------+-------+
6 rows in set (0.00 sec)

mysql> select * from s where name like"%i%";


+----------+----------+-------+---------+-------+---------------------------
+--------+------------+-------+
| admin_no | name | class | subject | marks | e_id |
marks2 | DOB | fees |
+----------+----------+-------+---------+-------+---------------------------
+--------+------------+-------+
| 724 | Savitri | 12 | Maths | 100 | [email protected] | 50
| 2007-11-20 | 50000 |
| 733 | Dwij | 12 | Maths | 97 | [email protected] | 42
| 2007-08-03 | 45000 |
| 763 | Vanshika | 12 | IP | 85 | [email protected] | 40
| 2007-09-08 | 49000 |
| 795 | Ashish | 12 | maths | 82 | [email protected] | 39
| 2007-06-10 | NULL |
+----------+----------+-------+---------+-------+---------------------------
+--------+------------+-------+
4 rows in set (0.00 sec)

mysql> alter table s drop class,subject;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'subject'
at line 1
mysql> alter table s drop class and subject;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'and
subject' at line 1
mysql> alter table s drop class;
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> alter table s drop subject;


Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> select * from s;


+----------+----------+-------+---------------------------+--------+------------
+-------+
| admin_no | name | marks | e_id | marks2 | DOB |
fees |
+----------+----------+-------+---------------------------+--------+------------
+-------+
| 723 | Sarneet | 100 | [email protected] | 50 | 2006-10-06 |
50000 |
| 724 | Savitri | 100 | [email protected] | 50 | 2007-11-20 |
50000 |
| 732 | Yuvraj | 98 | [email protected] | 45 | 2007-03-12 |
45000 |
| 733 | Dwij | 97 | [email protected] | 42 | 2007-08-03 |
45000 |
| 736 | Dhruv | 74 | [email protected] | 41 | 2007-02-14 |
44000 |
| 740 | Kangna | 51 | [email protected] | 20 | 2007-11-24 |
NULL |
| 763 | Vanshika | 85 | [email protected] | 40 | 2007-09-08 |
49000 |
| 795 | Ashish | 82 | [email protected] | 39 | 2007-06-10 |
NULL |
+----------+----------+-------+---------------------------+--------+------------
+-------+
8 rows in set (0.00 sec)

mysql> select * from s order by admin_no;


+----------+----------+-------+---------------------------+--------+------------
+-------+
| admin_no | name | marks | e_id | marks2 | DOB |
fees |
+----------+----------+-------+---------------------------+--------+------------
+-------+
| 723 | Sarneet | 100 | [email protected] | 50 | 2006-10-06 |
50000 |
| 724 | Savitri | 100 | [email protected] | 50 | 2007-11-20 |
50000 |
| 732 | Yuvraj | 98 | [email protected] | 45 | 2007-03-12 |
45000 |
| 733 | Dwij | 97 | [email protected] | 42 | 2007-08-03 |
45000 |
| 736 | Dhruv | 74 | [email protected] | 41 | 2007-02-14 |
44000 |
| 740 | Kangna | 51 | [email protected] | 20 | 2007-11-24 |
NULL |
| 763 | Vanshika | 85 | [email protected] | 40 | 2007-09-08 |
49000 |
| 795 | Ashish | 82 | [email protected] | 39 | 2007-06-10 |
NULL |
+----------+----------+-------+---------------------------+--------+------------
+-------+
8 rows in set (0.00 sec)

mysql> select * from s order by admin_no desc;


+----------+----------+-------+---------------------------+--------+------------
+-------+
| admin_no | name | marks | e_id | marks2 | DOB |
fees |
+----------+----------+-------+---------------------------+--------+------------
+-------+
| 795 | Ashish | 82 | [email protected] | 39 | 2007-06-10 |
NULL |
| 763 | Vanshika | 85 | [email protected] | 40 | 2007-09-08 |
49000 |
| 740 | Kangna | 51 | [email protected] | 20 | 2007-11-24 |
NULL |
| 736 | Dhruv | 74 | [email protected] | 41 | 2007-02-14 |
44000 |
| 733 | Dwij | 97 | [email protected] | 42 | 2007-08-03 |
45000 |
| 732 | Yuvraj | 98 | [email protected] | 45 | 2007-03-12 |
45000 |
| 724 | Savitri | 100 | [email protected] | 50 | 2007-11-20 |
50000 |
| 723 | Sarneet | 100 | [email protected] | 50 | 2006-10-06 |
50000 |
+----------+----------+-------+---------------------------+--------+------------
+-------+
8 rows in set (0.00 sec)

mysql> alter table s rename marks to marks1;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'to
marks1' at line 1
mysql> alter table s rename column marks to marks1;
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> select * from s order by admin_no;


+----------+----------+--------+---------------------------+--------+------------
+-------+
| admin_no | name | marks1 | e_id | marks2 | DOB |
fees |
+----------+----------+--------+---------------------------+--------+------------
+-------+
| 723 | Sarneet | 100 | [email protected] | 50 | 2006-10-06 |
50000 |
| 724 | Savitri | 100 | [email protected] | 50 | 2007-11-20 |
50000 |
| 732 | Yuvraj | 98 | [email protected] | 45 | 2007-03-12 |
45000 |
| 733 | Dwij | 97 | [email protected] | 42 | 2007-08-03 |
45000 |
| 736 | Dhruv | 74 | [email protected] | 41 | 2007-02-14 |
44000 |
| 740 | Kangna | 51 | [email protected] | 20 | 2007-11-24 |
NULL |
| 763 | Vanshika | 85 | [email protected] | 40 | 2007-09-08 |
49000 |
| 795 | Ashish | 82 | [email protected] | 39 | 2007-06-10 |
NULL |
+----------+----------+--------+---------------------------+--------+------------
+-------+
8 rows in set (0.00 sec)

mysql> select length(name) from s;


+--------------+
| length(name) |
+--------------+
| 7 |
| 7 |
| 6 |
| 4 |
| 5 |
| 6 |
| 8 |
| 6 |
+--------------+
8 rows in set (0.00 sec)

mysql> select name,length(name) from s;


+----------+--------------+
| name | length(name) |
+----------+--------------+
| Sarneet | 7 |
| Savitri | 7 |
| Yuvraj | 6 |
| Dwij | 4 |
| Dhruv | 5 |
| Kangna | 6 |
| Vanshika | 8 |
| Ashish | 6 |
+----------+--------------+
8 rows in set (0.00 sec)

mysql> select name,upper(name) from s;


+----------+-------------+
| name | upper(name) |
+----------+-------------+
| Sarneet | SARNEET |
| Savitri | SAVITRI |
| Yuvraj | YUVRAJ |
| Dwij | DWIJ |
| Dhruv | DHRUV |
| Kangna | KANGNA |
| Vanshika | VANSHIKA |
| Ashish | ASHISH |
+----------+-------------+
8 rows in set (0.00 sec)

mysql> select name,lower(name) from s;


+----------+-------------+
| name | lower(name) |
+----------+-------------+
| Sarneet | sarneet |
| Savitri | savitri |
| Yuvraj | yuvraj |
| Dwij | dwij |
| Dhruv | dhruv |
| Kangna | kangna |
| Vanshika | vanshika |
| Ashish | ashish |
+----------+-------------+
8 rows in set (0.00 sec)

mysql> select name,substr(name,) from s;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near ') from
s' at line 1
mysql> select name,substr(name,3) from s;
+----------+----------------+
| name | substr(name,3) |
+----------+----------------+
| Sarneet | rneet |
| Savitri | vitri |
| Yuvraj | vraj |
| Dwij | ij |
| Dhruv | ruv |
| Kangna | ngna |
| Vanshika | nshika |
| Ashish | hish |
+----------+----------------+
8 rows in set (0.00 sec)

mysql> select name,substr(name,4) from s;


+----------+----------------+
| name | substr(name,4) |
+----------+----------------+
| Sarneet | neet |
| Savitri | itri |
| Yuvraj | raj |
| Dwij | j |
| Dhruv | uv |
| Kangna | gna |
| Vanshika | shika |
| Ashish | ish |
+----------+----------------+
8 rows in set (0.00 sec)

mysql> select name,substr(name,2) from s;


+----------+----------------+
| name | substr(name,2) |
+----------+----------------+
| Sarneet | arneet |
| Savitri | avitri |
| Yuvraj | uvraj |
| Dwij | wij |
| Dhruv | hruv |
| Kangna | angna |
| Vanshika | anshika |
| Ashish | shish |
+----------+----------------+
8 rows in set (0.00 sec)

mysql> select name,substr(name,3) from s;


+----------+----------------+
| name | substr(name,3) |
+----------+----------------+
| Sarneet | rneet |
| Savitri | vitri |
| Yuvraj | vraj |
| Dwij | ij |
| Dhruv | ruv |
| Kangna | ngna |
| Vanshika | nshika |
| Ashish | hish |
+----------+----------------+
8 rows in set (0.00 sec)

mysql> select name,substr(name,3,2) from s;


+----------+------------------+
| name | substr(name,3,2) |
+----------+------------------+
| Sarneet | rn |
| Savitri | vi |
| Yuvraj | vr |
| Dwij | ij |
| Dhruv | ru |
| Kangna | ng |
| Vanshika | ns |
| Ashish | hi |
+----------+------------------+
8 rows in set (0.00 sec)

mysql> select name,substr(name,'s') from s;


+----------+------------------+
| name | substr(name,'s') |
+----------+------------------+
| Sarneet | |
| Savitri | |
| Yuvraj | |
| Dwij | |
| Dhruv | |
| Kangna | |
| Vanshika | |
| Ashish | |
+----------+------------------+
8 rows in set, 9 warnings (0.01 sec)

mysql> select name,instr(name,'s') from s;


+----------+-----------------+
| name | instr(name,'s') |
+----------+-----------------+
| Sarneet | 1 |
| Savitri | 1 |
| Yuvraj | 0 |
| Dwij | 0 |
| Dhruv | 0 |
| Kangna | 0 |
| Vanshika | 4 |
| Ashish | 2 |
+----------+-----------------+
8 rows in set (0.00 sec)

mysql> select now();


+---------------------+
| now() |
+---------------------+
| 2024-09-04 17:46:57 |
+---------------------+
1 row in set (0.01 sec)

mysql> select sysdate();


+---------------------+
| sysdate() |
+---------------------+
| 2024-09-04 17:47:03 |
+---------------------+
1 row in set (0.00 sec)

mysql> select curdate();


+------------+
| curdate() |
+------------+
| 2024-09-04 |
+------------+
1 row in set (0.01 sec)

mysql> select curtime();


+-----------+
| curtime() |
+-----------+
| 17:47:15 |
+-----------+
1 row in set (0.00 sec)

mysql> select date();


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near ')' at
line 1
mysql> select date("06-10-2006");
+--------------------+
| date("06-10-2006") |
+--------------------+
| NULL |
+--------------------+
1 row in set, 1 warning (0.00 sec)

mysql> select date("04-09-2024");


+--------------------+
| date("04-09-2024") |
+--------------------+
| NULL |
+--------------------+
1 row in set, 1 warning (0.00 sec)

mysql> select * from s where marks2 between 30 and 50;


+----------+----------+--------+---------------------------+--------+------------
+-------+
| admin_no | name | marks1 | e_id | marks2 | DOB |
fees |
+----------+----------+--------+---------------------------+--------+------------
+-------+
| 723 | Sarneet | 100 | [email protected] | 50 | 2006-10-06 |
50000 |
| 724 | Savitri | 100 | [email protected] | 50 | 2007-11-20 |
50000 |
| 732 | Yuvraj | 98 | [email protected] | 45 | 2007-03-12 |
45000 |
| 733 | Dwij | 97 | [email protected] | 42 | 2007-08-03 |
45000 |
| 736 | Dhruv | 74 | [email protected] | 41 | 2007-02-14 |
44000 |
| 763 | Vanshika | 85 | [email protected] | 40 | 2007-09-08 |
49000 |
| 795 | Ashish | 82 | [email protected] | 39 | 2007-06-10 |
NULL |
+----------+----------+--------+---------------------------+--------+------------
+-------+
7 rows in set (0.01 sec)

mysql> select name,marks2 from s where marks2 between 30 and 50;


+----------+--------+
| name | marks2 |
+----------+--------+
| Sarneet | 50 |
| Savitri | 50 |
| Yuvraj | 45 |
| Dwij | 42 |
| Dhruv | 41 |
| Vanshika | 40 |
| Ashish | 39 |
+----------+--------+
7 rows in set (0.00 sec)

mysql> select * from s where name not in("kangna");


+----------+----------+--------+---------------------------+--------+------------
+-------+
| admin_no | name | marks1 | e_id | marks2 | DOB |
fees |
+----------+----------+--------+---------------------------+--------+------------
+-------+
| 723 | Sarneet | 100 | [email protected] | 50 | 2006-10-06 |
50000 |
| 724 | Savitri | 100 | [email protected] | 50 | 2007-11-20 |
50000 |
| 732 | Yuvraj | 98 | [email protected] | 45 | 2007-03-12 |
45000 |
| 733 | Dwij | 97 | [email protected] | 42 | 2007-08-03 |
45000 |
| 736 | Dhruv | 74 | [email protected] | 41 | 2007-02-14 |
44000 |
| 763 | Vanshika | 85 | [email protected] | 40 | 2007-09-08 |
49000 |
| 795 | Ashish | 82 | [email protected] | 39 | 2007-06-10 |
NULL |
+----------+----------+--------+---------------------------+--------+------------
+-------+
7 rows in set (0.00 sec)

mysql> select * from s where name not in("dhruv");


+----------+----------+--------+---------------------------+--------+------------
+-------+
| admin_no | name | marks1 | e_id | marks2 | DOB |
fees |
+----------+----------+--------+---------------------------+--------+------------
+-------+
| 723 | Sarneet | 100 | [email protected] | 50 | 2006-10-06 |
50000 |
| 724 | Savitri | 100 | [email protected] | 50 | 2007-11-20 |
50000 |
| 732 | Yuvraj | 98 | [email protected] | 45 | 2007-03-12 |
45000 |
| 733 | Dwij | 97 | [email protected] | 42 | 2007-08-03 |
45000 |
| 740 | Kangna | 51 | [email protected] | 20 | 2007-11-24 |
NULL |
| 763 | Vanshika | 85 | [email protected] | 40 | 2007-09-08 |
49000 |
| 795 | Ashish | 82 | [email protected] | 39 | 2007-06-10 |
NULL |
+----------+----------+--------+---------------------------+--------+------------
+-------+
7 rows in set (0.00 sec)

mysql> select * from s where name not in("dhruv,ashish,dwij");


+----------+----------+--------+---------------------------+--------+------------
+-------+
| admin_no | name | marks1 | e_id | marks2 | DOB |
fees |
+----------+----------+--------+---------------------------+--------+------------
+-------+
| 723 | Sarneet | 100 | [email protected] | 50 | 2006-10-06 |
50000 |
| 724 | Savitri | 100 | [email protected] | 50 | 2007-11-20 |
50000 |
| 732 | Yuvraj | 98 | [email protected] | 45 | 2007-03-12 |
45000 |
| 733 | Dwij | 97 | [email protected] | 42 | 2007-08-03 |
45000 |
| 736 | Dhruv | 74 | [email protected] | 41 | 2007-02-14 |
44000 |
| 740 | Kangna | 51 | [email protected] | 20 | 2007-11-24 |
NULL |
| 763 | Vanshika | 85 | [email protected] | 40 | 2007-09-08 |
49000 |
| 795 | Ashish | 82 | [email protected] | 39 | 2007-06-10 |
NULL |
+----------+----------+--------+---------------------------+--------+------------
+-------+
8 rows in set (0.00 sec)

mysql> select * from s where name not in("dhruv");


+----------+----------+--------+---------------------------+--------+------------
+-------+
| admin_no | name | marks1 | e_id | marks2 | DOB |
fees |
+----------+----------+--------+---------------------------+--------+------------
+-------+
| 723 | Sarneet | 100 | [email protected] | 50 | 2006-10-06 |
50000 |
| 724 | Savitri | 100 | [email protected] | 50 | 2007-11-20 |
50000 |
| 732 | Yuvraj | 98 | [email protected] | 45 | 2007-03-12 |
45000 |
| 733 | Dwij | 97 | [email protected] | 42 | 2007-08-03 |
45000 |
| 740 | Kangna | 51 | [email protected] | 20 | 2007-11-24 |
NULL |
| 763 | Vanshika | 85 | [email protected] | 40 | 2007-09-08 |
49000 |
| 795 | Ashish | 82 | [email protected] | 39 | 2007-06-10 |
NULL |
+----------+----------+--------+---------------------------+--------+------------
+-------+
7 rows in set (0.00 sec)

mysql>

You might also like