0% found this document useful (0 votes)
31 views13 pages

Microsoft Windows

The document shows the logging into a MariaDB database server using the mysql command line tool. It then shows the available databases and selects the school database. Various queries are run on tables like dishes and users to showcase LIKE pattern matching. Mathematical functions like CEIL, POW, FLOOR etc are also demonstrated. Finally, a new salary table is created and some data is inserted before running queries on it.

Uploaded by

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

Microsoft Windows

The document shows the logging into a MariaDB database server using the mysql command line tool. It then shows the available databases and selects the school database. Various queries are run on tables like dishes and users to showcase LIKE pattern matching. Mathematical functions like CEIL, POW, FLOOR etc are also demonstrated. Finally, a new salary table is created and some data is inserted before running queries on it.

Uploaded by

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

Microsoft Windows [Version 10.0.19045.

3570]

(c) Microsoft Corporation. All rights reserved.

C:\xampp\mysql\bin>mysql -u root -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 8

Server version: 10.4.22-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;

+--------------------+

| Database |

+--------------------+

| db_demo |

| db_laravel |

| db_one |

| dbcontact |

| dbmyshop |

| dbpractice |

| dbtest |

| hr |

| information_schema |

| laravel |

| max_db |

| mydb |
| mysql |

| performance_schema |

| phpmyadmin |

| school |

+--------------------+

16 rows in set (0.031 sec)

MariaDB [(none)]> use school;

Database changed

MariaDB [school]> show tabels;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
MariaDB server version for the right syntax to use near 'tabels' at line 1

MariaDB [school]> show tables;

+------------------+

| Tables_in_school |

+------------------+

|a |

| asd |

| asda |

| dishes |

| faculty |

| helloa |

| lab_number |

| maaz |

| users |

+------------------+

9 rows in set (0.001 sec)

MariaDB [school]> select * from dishes;


+----+----------------+

| id | dish_name |

+----+----------------+

| 1 | Biryani |

| 2 | qourma |

| 3 | chicken karhai |

| 4 | Mutton Karahi |

| 5 | CHAPLI KABAB |

+----+----------------+

5 rows in set (0.014 sec)

MariaDB [school]> select * from dishes where dish_name Like "b%";

+----+-----------+

| id | dish_name |

+----+-----------+

| 1 | Biryani |

+----+-----------+

1 row in set (0.000 sec)

MariaDB [school]> select * from dishes where dish_name Like "%b";

+----+--------------+

| id | dish_name |

+----+--------------+

| 5 | CHAPLI KABAB |

+----+--------------+

1 row in set (0.000 sec)

MariaDB [school]> select * from dishes where dish_name Like "%c";

Empty set (0.000 sec)


MariaDB [school]> select * from dishes where dish_name Like "c%";

+----+----------------+

| id | dish_name |

+----+----------------+

| 3 | chicken karhai |

| 5 | CHAPLI KABAB |

+----+----------------+

2 rows in set (0.000 sec)

MariaDB [school]> select * from dishes where dish_name Like "c_a%";

+----+--------------+

| id | dish_name |

+----+--------------+

| 5 | CHAPLI KABAB |

+----+--------------+

1 row in set (0.000 sec)

MariaDB [school]> select * from dishes where dish_name Like "c_b%";

Empty set (0.000 sec)

MariaDB [school]> select * from dishes where dish_name Like "c_i%";

+----+----------------+

| id | dish_name |

+----+----------------+

| 3 | chicken karhai |

+----+----------------+

1 row in set (0.000 sec)


MariaDB [school]> select * from dishes where dish_name Like "c_i_k%";

+----+----------------+

| id | dish_name |

+----+----------------+

| 3 | chicken karhai |

+----+----------------+

1 row in set (0.000 sec)

MariaDB [school]> select * from dishes where dish_name Like "c__c%";

+----+----------------+

| id | dish_name |

+----+----------------+

| 3 | chicken karhai |

+----+----------------+

1 row in set (0.000 sec)

MariaDB [school]> select * from dishes where dish_name Like "c__p%";

+----+--------------+

| id | dish_name |

+----+--------------+

| 5 | CHAPLI KABAB |

+----+--------------+

1 row in set (0.000 sec)

MariaDB [school]> select * from dishes where dish_name Like "c%b";

+----+--------------+

| id | dish_name |

+----+--------------+

| 5 | CHAPLI KABAB |
+----+--------------+

1 row in set (0.000 sec)

MariaDB [school]> select * from dishes where dish_name Like "c%i";

+----+----------------+

| id | dish_name |

+----+----------------+

| 3 | chicken karhai |

+----+----------------+

1 row in set (0.000 sec)

MariaDB [school]> show tables;

+------------------+

| Tables_in_school |

+------------------+

|a |

| asd |

| asda |

| dishes |

| faculty |

| helloa |

| lab_number |

| maaz |

| users |

+------------------+

9 rows in set (0.001 sec)

MariaDB [school]> select * from users;

+----+--------+----------+
| id | name | order_id |

+----+--------+----------+

| 2 | MAAZ | 4|

| 3 | OSAMA | 4|

| 4 | ali | 3|

| 5 | aliyan | 2|

| 6 | almas | 2|

| 7 | maaz | 1|

+----+--------+----------+

6 rows in set (0.009 sec)

MariaDB [school]> select * from users where name Like "a_i%";

+----+--------+----------+

| id | name | order_id |

+----+--------+----------+

| 4 | ali | 3|

| 5 | aliyan | 2|

+----+--------+----------+

2 rows in set (0.000 sec)

MariaDB [school]> select * from dishes where dish_name Like "%ka%";

+----+----------------+

| id | dish_name |

+----+----------------+

| 3 | chicken karhai |

| 4 | Mutton Karahi |

| 5 | CHAPLI KABAB |

+----+----------------+

3 rows in set (0.000 sec)


MariaDB [school]> select ceil(24.4);

+------------+

| ceil(24.4) |

+------------+

| 25 |

+------------+

1 row in set (0.000 sec)

MariaDB [school]> select ceil(24.4) as "answer";

+--------+

| answer |

+--------+

| 25 |

+--------+

1 row in set (0.000 sec)

MariaDB [school]> select pow(2,3) as "answer";

+--------+

| answer |

+--------+

| 8|

+--------+

1 row in set (0.000 sec)

MariaDB [school]> select pow(2,8) as "answer";

+--------+

| answer |

+--------+
| 256 |

+--------+

1 row in set (0.000 sec)

MariaDB [school]> select floor(54.9);

+-------------+

| floor(54.9) |

+-------------+

| 54 |

+-------------+

1 row in set (0.000 sec)

MariaDB [school]> select pi();

+----------+

| pi() |

+----------+

| 3.141593 |

+----------+

1 row in set (0.000 sec)

MariaDB [school]> select sqrt(4);

+---------+

| sqrt(4) |

+---------+

| 2|

+---------+

1 row in set (0.000 sec)

MariaDB [school]> select round(52.5);


+-------------+

| round(52.5) |

+-------------+

| 53 |

+-------------+

1 row in set (0.000 sec)

MariaDB [school]> select * from dishes;

+----+----------------+

| id | dish_name |

+----+----------------+

| 1 | Biryani |

| 2 | qourma |

| 3 | chicken karhai |

| 4 | Mutton Karahi |

| 5 | CHAPLI KABAB |

+----+----------------+

5 rows in set (0.000 sec)

MariaDB [school]> select count(id) from dishes;

+-----------+

| count(id) |

+-----------+

| 5|

+-----------+

1 row in set (0.000 sec)

MariaDB [school]> select min(id) from dishes;

+---------+
| min(id) |

+---------+

| 1|

+---------+

1 row in set (0.000 sec)

MariaDB [school]> select max(id) from dishes;

+---------+

| max(id) |

+---------+

| 5|

+---------+

1 row in set (0.000 sec)

MariaDB [school]> select sum(id) from dishes;

+---------+

| sum(id) |

+---------+

| 15 |

+---------+

1 row in set (0.000 sec)

MariaDB [school]> select avg(id) from dishes;

+---------+

| avg(id) |

+---------+

| 3.0000 |

+---------+

1 row in set (0.000 sec)


MariaDB [school]> create table salary(

-> id int

-> ,

-> user_name varchar(20),

-> salary varchar(20)

-> );

Query OK, 0 rows affected (0.026 sec)

MariaDB [school]> insert into salary (user_name,salary) values ("MAAZ","200000"),("ADBUL


REHMAN","100000"),("UNZILA","50000"),("DANIYAL","80000");

Query OK, 4 rows affected (0.005 sec)

Records: 4 Duplicates: 0 Warnings: 0

MariaDB [school]> select * from salary;

+------+--------------+--------+

| id | user_name | salary |

+------+--------------+--------+

| NULL | MAAZ | 200000 |

| NULL | ADBUL REHMAN | 100000 |

| NULL | UNZILA | 50000 |

| NULL | DANIYAL | 80000 |

+------+--------------+--------+

4 rows in set (0.000 sec)

MariaDB [school]> select * from salary where salary <100000;

+------+-----------+--------+

| id | user_name | salary |

+------+-----------+--------+
| NULL | UNZILA | 50000 |

| NULL | DANIYAL | 80000 |

+------+-----------+--------+

2 rows in set (0.000 sec)

MariaDB [school]> select * from salary where salary =(select min(salary) from salary);

+------+--------------+--------+

| id | user_name | salary |

+------+--------------+--------+

| NULL | ADBUL REHMAN | 100000 |

+------+--------------+--------+

1 row in set (0.002 sec)

MariaDB [school]> select min(salary) from salary;

+-------------+

| min(salary) |

+-------------+

| 100000 |

+-------------+

1 row in set (0.000 sec)

MariaDB [school]>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy