0% found this document useful (0 votes)
28 views14 pages

XAMPP For Windows - Mysql - H Localhost - U Root - P

The document details steps taken in a MySQL database to set up tables, insert and query data. It creates student and branch tables, inserts data, updates and deletes rows, and runs queries on the tables.

Uploaded by

tcoffopharell
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)
28 views14 pages

XAMPP For Windows - Mysql - H Localhost - U Root - P

The document details steps taken in a MySQL database to set up tables, insert and query data. It creates student and branch tables, inserts data, updates and deletes rows, and runs queries on the tables.

Uploaded by

tcoffopharell
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/ 14

Setting environment for using XAMPP for Windows.

user@DESKTOP-3GSP4U4 c:\xampp
# mysql -h localhost -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.4.28-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)]> use gest_student;


Database changed
MariaDB [gest_student]> desc branch;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| id_branch | int(10) | NO | PRI | NULL | |
| nom | varchar(50) | YES | | NULL | |
| code_branch | varchar(10) | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+
3 rows in set (0.003 sec)

MariaDB [gest_student]> insert into branch values (2, 'maitenance', 'mt1'),(3,


'secretariat', 'sct1');
Query OK, 2 rows affected (0.003 sec)
Records: 2 Duplicates: 0 Warnings: 0

MariaDB [gest_student]> select * from branch;


+-----------+-------------+-------------+
| id_branch | nom | code_branch |
+-----------+-------------+-------------+
| 1 | science | s1 |
| 2 | maitenance | mt1 |
| 3 | secretariat | sct1 |
+-----------+-------------+-------------+
3 rows in set (0.000 sec)

MariaDB [gest_student]> desc student;


+---------------+--------------+------+-----+---------------------
+-------------------------------+
| Field | Type | Null | Key | Default | Extra
|
+---------------+--------------+------+-----+---------------------
+-------------------------------+
| id_student | int(8) | NO | PRI | NULL | auto_increment
|
| Name_student | varchar(20) | YES | | NULL |
|
| prenom | varchar(20) | YES | | NULL |
|
| date_naiss | date | YES | | NULL |
|
| adresse_email | varchar(40) | YES | | NULL |
|
| password | varchar(100) | YES | | NULL |
|
| date_creation | timestamp | NO | | current_timestamp() | on update
current_timestamp() |
| status | tinyint(1) | YES | | NULL |
|
| id_branch | int(10) | YES | MUL | NULL |
|
+---------------+--------------+------+-----+---------------------
+-------------------------------+
9 rows in set (0.003 sec)

MariaDB [gest_student]> insert into student values(2, 'fokou', 'diop', '2005-10-


12', 'diopfokou@gmail.com', 'qwu21e1', now(), 0, 2), (3, 'kamdem', 'leo', '1999-
02-13', 'ee2e2', now(), 0, 3);
ERROR 1136 (21S01): Column count doesn't match value count at row 2
MariaDB [gest_student]> insert into student values(2, 'fokou', 'diop', '2005-10-
12', 'diopfokou@gmail.com', 'qwu21e1', now(), 0, 2), (3, 'kamdem', 'leo', '1999-
02-13','leokamdem@gmail.com', 'ee2e2', now(),0, 3);
Query OK, 2 rows affected (0.003 sec)
Records: 2 Duplicates: 0 Warnings: 0

MariaDB [gest_student]> select * from student;


+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password
| date_creation | status | id_branch |
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
| 1 | Mba | Dave | 0000-00-00 | mbadave@gmail.com | mba12
| 2023-12-08 14:34:30 | 1 | 1 |
| 2 | fokou | diop | 2005-10-12 | diopfokou@gmail.com | qwu21e1
| 2023-12-08 14:49:03 | 0 | 2 |
| 3 | kamdem | leo | 1999-02-13 | leokamdem@gmail.com | ee2e2
| 2023-12-08 14:49:03 | 0 | 3 |
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
3 rows in set (0.000 sec)

MariaDB [gest_student]> insert into student values(4, 'sob', 'sako', '1995-10-02',


'sakosop@gmail.com','qfwese1', now(), 1, 1), (5, 'kuete', 'brice', '2009-12-
13','bricekuete@gmail.com', '43sf2', now(), 1, 2),(6, 'yaya', 'sako', '2001-01-02',
'sakoyaya@gmail.com', 'wwxaf1', now(), 0, 3);
Query OK, 3 rows affected (0.003 sec)
Records: 3 Duplicates: 0 Warnings: 0

MariaDB [gest_student]> select * from student;


+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password
| date_creation | status | id_branch |
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
| 1 | Mba | Dave | 0000-00-00 | mbadave@gmail.com | mba12
| 2023-12-08 14:34:30 | 1 | 1 |
| 2 | fokou | diop | 2005-10-12 | diopfokou@gmail.com | qwu21e1
| 2023-12-08 14:49:03 | 0 | 2 |
| 3 | kamdem | leo | 1999-02-13 | leokamdem@gmail.com | ee2e2
| 2023-12-08 14:49:03 | 0 | 3 |
| 4 | sob | sako | 1995-10-02 | sakosop@gmail.com | qfwese1
| 2023-12-08 14:54:55 | 1 | 1 |
| 5 | kuete | brice | 2009-12-13 | bricekuete@gmail.com | 43sf2
| 2023-12-08 14:54:55 | 1 | 2 |
| 6 | yaya | sako | 2001-01-02 | sakoyaya@gmail.com | wwxaf1
| 2023-12-08 14:54:55 | 0 | 3 |
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
6 rows in set (0.000 sec)

MariaDB [gest_student]> update student set date_naiss = '1998-03-15' where id = 1;


ERROR 1054 (42S22): Unknown column 'id' in 'where clause'
MariaDB [gest_student]> update student set date_naiss = '1998-03-15' where
id_student = 1;
Query OK, 1 row affected (0.004 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [gest_student]> insert into student values( 7, 'zoro', 'lea', '2005-08-09',


'duqwd@gmail.com', 'wdqf0', now(), 0,1 );
Query OK, 1 row affected (0.003 sec)

MariaDB [gest_student]> delete from student where id_Student = 7;


Query OK, 1 row affected (0.003 sec)

MariaDB [gest_student]> desc student;


+---------------+--------------+------+-----+---------------------
+-------------------------------+
| Field | Type | Null | Key | Default | Extra
|
+---------------+--------------+------+-----+---------------------
+-------------------------------+
| id_student | int(8) | NO | PRI | NULL | auto_increment
|
| Name_student | varchar(20) | YES | | NULL |
|
| prenom | varchar(20) | YES | | NULL |
|
| date_naiss | date | YES | | NULL |
|
| adresse_email | varchar(40) | YES | | NULL |
|
| password | varchar(100) | YES | | NULL |
|
| date_creation | timestamp | NO | | current_timestamp() | on update
current_timestamp() |
| status | tinyint(1) | YES | | NULL |
|
| id_branch | int(10) | YES | MUL | NULL |
|
+---------------+--------------+------+-----+---------------------
+-------------------------------+
9 rows in set (0.003 sec)

MariaDB [gest_student]> select * from student;


+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password
| date_creation | status | id_branch |
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
| 1 | Mba | Dave | 1998-03-15 | mbadave@gmail.com | mba12
| 2023-12-08 15:01:17 | 1 | 1 |
| 2 | fokou | diop | 2005-10-12 | diopfokou@gmail.com | qwu21e1
| 2023-12-08 14:49:03 | 0 | 2 |
| 3 | kamdem | leo | 1999-02-13 | leokamdem@gmail.com | ee2e2
| 2023-12-08 14:49:03 | 0 | 3 |
| 4 | sob | sako | 1995-10-02 | sakosop@gmail.com | qfwese1
| 2023-12-08 14:54:55 | 1 | 1 |
| 5 | kuete | brice | 2009-12-13 | bricekuete@gmail.com | 43sf2
| 2023-12-08 14:54:55 | 1 | 2 |
| 6 | yaya | sako | 2001-01-02 | sakoyaya@gmail.com | wwxaf1
| 2023-12-08 14:54:55 | 0 | 3 |
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
6 rows in set (0.000 sec)

MariaDB [gest_student]> select from branch;


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 'from
branch' at line 1
MariaDB [gest_student]> select Name_student, prenom from student;
+--------------+--------+
| Name_student | prenom |
+--------------+--------+
| Mba | Dave |
| fokou | diop |
| kamdem | leo |
| sob | sako |
| kuete | brice |
| yaya | sako |
+--------------+--------+
6 rows in set (0.001 sec)

MariaDB [gest_student]> select distinct id_branch from student;


+-----------+
| id_branch |
+-----------+
| 1 |
| 2 |
| 3 |
+-----------+
3 rows in set (0.001 sec)

MariaDB [gest_student]> select * from student where statut=0;


ERROR 1054 (42S22): Unknown column 'statut' in 'where clause'
MariaDB [gest_student]> select * from student where statut = 0;
ERROR 1054 (42S22): Unknown column 'statut' in 'where clause'
MariaDB [gest_student]> select * from student where status=0;
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password
| date_creation | status | id_branch |
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
| 2 | fokou | diop | 2005-10-12 | diopfokou@gmail.com | qwu21e1
| 2023-12-08 14:49:03 | 0 | 2 |
| 3 | kamdem | leo | 1999-02-13 | leokamdem@gmail.com | ee2e2
| 2023-12-08 14:49:03 | 0 | 3 |
| 6 | yaya | sako | 2001-01-02 | sakoyaya@gmail.com | wwxaf1
| 2023-12-08 14:54:55 | 0 | 3 |
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
3 rows in set (0.001 sec)

MariaDB [gest_student]> select * from student where id_student !=3;


+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password
| date_creation | status | id_branch |
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
| 1 | Mba | Dave | 1998-03-15 | mbadave@gmail.com | mba12
| 2023-12-08 15:01:17 | 1 | 1 |
| 2 | fokou | diop | 2005-10-12 | diopfokou@gmail.com | qwu21e1
| 2023-12-08 14:49:03 | 0 | 2 |
| 4 | sob | sako | 1995-10-02 | sakosop@gmail.com | qfwese1
| 2023-12-08 14:54:55 | 1 | 1 |
| 5 | kuete | brice | 2009-12-13 | bricekuete@gmail.com | 43sf2
| 2023-12-08 14:54:55 | 1 | 2 |
| 6 | yaya | sako | 2001-01-02 | sakoyaya@gmail.com | wwxaf1
| 2023-12-08 14:54:55 | 0 | 3 |
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
5 rows in set (0.001 sec)

MariaDB [gest_student]> select * from student where id_student !=3 & 4;


+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password
| date_creation | status | id_branch |
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
| 1 | Mba | Dave | 1998-03-15 | mbadave@gmail.com | mba12
| 2023-12-08 15:01:17 | 1 | 1 |
| 2 | fokou | diop | 2005-10-12 | diopfokou@gmail.com | qwu21e1
| 2023-12-08 14:49:03 | 0 | 2 |
| 3 | kamdem | leo | 1999-02-13 | leokamdem@gmail.com | ee2e2
| 2023-12-08 14:49:03 | 0 | 3 |
| 4 | sob | sako | 1995-10-02 | sakosop@gmail.com | qfwese1
| 2023-12-08 14:54:55 | 1 | 1 |
| 5 | kuete | brice | 2009-12-13 | bricekuete@gmail.com | 43sf2
| 2023-12-08 14:54:55 | 1 | 2 |
| 6 | yaya | sako | 2001-01-02 | sakoyaya@gmail.com | wwxaf1
| 2023-12-08 14:54:55 | 0 | 3 |
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
6 rows in set (0.001 sec)

MariaDB [gest_student]> select * from student where id_student !=3,4,5,6;


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 '4,5,6'
at line 1
MariaDB [gest_student]> select * from student where id_student !=3, id_student !=
4;
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 '
id_student != 4' at line 1
MariaDB [gest_student]> select * from student where id_student !=3 and id_student !
=5;
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password
| date_creation | status | id_branch |
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
| 1 | Mba | Dave | 1998-03-15 | mbadave@gmail.com | mba12
| 2023-12-08 15:01:17 | 1 | 1 |
| 2 | fokou | diop | 2005-10-12 | diopfokou@gmail.com | qwu21e1
| 2023-12-08 14:49:03 | 0 | 2 |
| 4 | sob | sako | 1995-10-02 | sakosop@gmail.com | qfwese1
| 2023-12-08 14:54:55 | 1 | 1 |
| 6 | yaya | sako | 2001-01-02 | sakoyaya@gmail.com | wwxaf1
| 2023-12-08 14:54:55 | 0 | 3 |
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
4 rows in set (0.000 sec)

MariaDB [gest_student]> select * from student where status= 1 and id_branch=1 or


status=2 and id_branch= 2;
+------------+--------------+--------+------------+-------------------+----------
+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password |
date_creation | status | id_branch |
+------------+--------------+--------+------------+-------------------+----------
+---------------------+--------+-----------+
| 1 | Mba | Dave | 1998-03-15 | mbadave@gmail.com | mba12 |
2023-12-08 15:01:17 | 1 | 1 |
| 4 | sob | sako | 1995-10-02 | sakosop@gmail.com | qfwese1 |
2023-12-08 14:54:55 | 1 | 1 |
+------------+--------------+--------+------------+-------------------+----------
+---------------------+--------+-----------+
2 rows in set (0.001 sec)

MariaDB [gest_student]> select * from student where status= 1 and id_branch=1 or


status=0 and id_branch= 2;
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password
| date_creation | status | id_branch |
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
| 1 | Mba | Dave | 1998-03-15 | mbadave@gmail.com | mba12
| 2023-12-08 15:01:17 | 1 | 1 |
| 2 | fokou | diop | 2005-10-12 | diopfokou@gmail.com | qwu21e1
| 2023-12-08 14:49:03 | 0 | 2 |
| 4 | sob | sako | 1995-10-02 | sakosop@gmail.com | qfwese1
| 2023-12-08 14:54:55 | 1 | 1 |
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
3 rows in set (0.001 sec)

MariaDB [gest_student]> select * from student where date_naiss between '1990-01-01'


and '2005-12-30';
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password
| date_creation | status | id_branch |
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
| 1 | Mba | Dave | 1998-03-15 | mbadave@gmail.com | mba12
| 2023-12-08 15:01:17 | 1 | 1 |
| 2 | fokou | diop | 2005-10-12 | diopfokou@gmail.com | qwu21e1
| 2023-12-08 14:49:03 | 0 | 2 |
| 3 | kamdem | leo | 1999-02-13 | leokamdem@gmail.com | ee2e2
| 2023-12-08 14:49:03 | 0 | 3 |
| 4 | sob | sako | 1995-10-02 | sakosop@gmail.com | qfwese1
| 2023-12-08 14:54:55 | 1 | 1 |
| 6 | yaya | sako | 2001-01-02 | sakoyaya@gmail.com | wwxaf1
| 2023-12-08 14:54:55 | 0 | 3 |
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
5 rows in set (0.000 sec)

MariaDB [gest_student]> select * from student where Name_student like '%a';


+------------+--------------+--------+------------+--------------------+----------
+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password |
date_creation| status | id_branch |
+------------+--------------+--------+------------+--------------------+----------
+---------------------+--------+-----------+
| 1 | Mba | Dave | 1998-03-15 | mbadave@gmail.com | mba12 |
2023-12-08 15:01:17| 1 | 1 |
| 6 | yaya | sako | 2001-01-02 | sakoyaya@gmail.com | wwxaf1 |
2023-12-08 14:54:55| 0 | 3 |
+------------+--------------+--------+------------+--------------------+----------
+---------------------+--------+-----------+
2 rows in set (0.001 sec)

MariaDB [gest_student]> select * from student where Name_student like '%u';


+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password
| date_creation | status | id_branch |
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
| 2 | fokou | diop | 2005-10-12 | diopfokou@gmail.com | qwu21e1
| 2023-12-08 14:49:03 | 0 | 2 |
+------------+--------------+--------+------------+---------------------+----------
+---------------------+--------+-----------+
1 row in set (0.000 sec)

MariaDB [gest_student]> select * from student where Name_student like '%u' or


prenom like '%e';
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password
| date_creation | status | id_branch |
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
| 1 | Mba | Dave | 1998-03-15 | mbadave@gmail.com | mba12
| 2023-12-08 15:01:17 | 1 | 1 |
| 2 | fokou | diop | 2005-10-12 | diopfokou@gmail.com | qwu21e1
| 2023-12-08 14:49:03 | 0 | 2 |
| 5 | kuete | brice | 2009-12-13 | bricekuete@gmail.com | 43sf2
| 2023-12-08 14:54:55 | 1 | 2 |
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
3 rows in set (0.000 sec)

MariaDB [gest_student]> select * from student where Name_student like 's%' or


prenom like 'y%';
+------------+--------------+--------+------------+-------------------+----------
+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password |
date_creation | status | id_branch |
+------------+--------------+--------+------------+-------------------+----------
+---------------------+--------+-----------+
| 4 | sob | sako | 1995-10-02 | sakosop@gmail.com | qfwese1 |
2023-12-08 14:54:55 | 1 | 1 |
+------------+--------------+--------+------------+-------------------+----------
+---------------------+--------+-----------+
1 row in set (0.000 sec)

MariaDB [gest_student]> select * from student where Name_student like 'y%';


+------------+--------------+--------+------------+--------------------+----------
+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password |
date_creation| status | id_branch |
+------------+--------------+--------+------------+--------------------+----------
+---------------------+--------+-----------+
| 6 | yaya | sako | 2001-01-02 | sakoyaya@gmail.com | wwxaf1 |
2023-12-08 14:54:55| 0 | 3 |
+------------+--------------+--------+------------+--------------------+----------
+---------------------+--------+-----------+
1 row in set (0.000 sec)

MariaDB [gest_student]>
MariaDB [gest_student]>
MariaDB [gest_student]> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| gest_student |
| information_schema |
| library |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
+--------------------+
7 rows in set (0.001 sec)

MariaDB [gest_student]> close database gest_student


-> ;
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 'close
database gest_student' at line 1
MariaDB [gest_student]> exit database gest_student;
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 'exit
database gest_student' at line 1
MariaDB [gest_student]> exit gest_student;
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 'exit
gest_student' at line 1
MariaDB [gest_student]> leave gest_student;
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 'leave
gest_student' at line 1
MariaDB [gest_student]> close gest_student;
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 'close
gest_student' at line 1
MariaDB [gest_student]> quite
-> ;
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 'quite'
at line 1
MariaDB [gest_student]> quit gest_student;
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 'quit
gest_student' at line 1
MariaDB [gest_student]> fuck it;
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 'fuck
it' at line 1
MariaDB [gest_student]> select * from student where status is not null;
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
| id_student | Name_student | prenom | date_naiss | adresse_email | password
| date_creation | status | id_branch |
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
| 1 | Mba | Dave | 1998-03-15 | mbadave@gmail.com | mba12
| 2023-12-08 15:01:17 | 1 | 1 |
| 2 | fokou | diop | 2005-10-12 | diopfokou@gmail.com | qwu21e1
| 2023-12-08 14:49:03 | 0 | 2 |
| 3 | kamdem | leo | 1999-02-13 | leokamdem@gmail.com | ee2e2
| 2023-12-08 14:49:03 | 0 | 3 |
| 4 | sob | sako | 1995-10-02 | sakosop@gmail.com | qfwese1
| 2023-12-08 14:54:55 | 1 | 1 |
| 5 | kuete | brice | 2009-12-13 | bricekuete@gmail.com | 43sf2
| 2023-12-08 14:54:55 | 1 | 2 |
| 6 | yaya | sako | 2001-01-02 | sakoyaya@gmail.com | wwxaf1
| 2023-12-08 14:54:55 | 0 | 3 |
+------------+--------------+--------+------------+----------------------
+----------+---------------------+--------+-----------+
6 rows in set (0.001 sec)

MariaDB [gest_student]> select * from student and branch where id_branch= 2;


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 'and
branch where id_branch= 2' at line 1
MariaDB [gest_student]> select from id_student, Name_student, prenom, id_branch
from student INNER JOINbranch ON student.id_branch = branch.id_branch;
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 'from
id_student, Name_student, prenom, id_branch from student INNER JOIN bran...' at
line 1
MariaDB [gest_student]> select id_student, Name_student, prenom, id_branch from
student INNER JOIN branch ON student.id_branch = branch.id_branch;
ERROR 1052 (23000): Column 'id_branch' in field list is ambiguous
MariaDB [gest_student]> select id_student, Name_student, prenom, id_branch from
student INNER JOIN branch ON student.id_branch = branch.id_branch where
id_branch=2;
ERROR 1052 (23000): Column 'id_branch' in field list is ambiguous
MariaDB [gest_student]> select id_student, Name_student, prenom, nom from student
INNER JOIN branch ON student.id_branch = branch.id_branch where id_branch=2;
ERROR 1052 (23000): Column 'id_branch' in where clause is ambiguous
MariaDB [gest_student]> select id_student, Name_student, nom from student INNER
JOIN branch ON student.id_branch = branch.id_branch where id_branch=2;
ERROR 1052 (23000): Column 'id_branch' in where clause is ambiguous
MariaDB [gest_student]> select id_student, Name_student, nom from student INNER
JOIN branch ON student.id_branch = branch.id_branch where id_branch=2;
ERROR 1052 (23000): Column 'id_branch' in where clause is ambiguous
MariaDB [gest_student]> use library;
Database changed
MariaDB [library]> show tables;
+-------------------+
| Tables_in_library |
+-------------------+
| books |
| issue |
+-------------------+
2 rows in set (0.001 sec)

MariaDB [library]> desc books;


+---------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| accession_num | int(10) | YES | | NULL | |
| book_name | varchar(100) | YES | | NULL | |
| Author_name | varchar(100) | YES | | NULL | |
| num_pages | int(7) | YES | | NULL | |
+---------------+--------------+------+-----+---------+-------+
4 rows in set (0.013 sec)

MariaDB [library]> desc issue;


+---------------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------+------+-----+---------+-------+
| student_num | int(10) | YES | | NULL | |
| accession_num | int(10) | YES | | NULL | |
| DOI | date | YES | | NULL | |
+---------------+---------+------+-----+---------+-------+
3 rows in set (0.008 sec)

MariaDB [library]> ALTER TABLE Persons


-> primary key (accession_num);
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
'primary key (accession_num)' at line 2
MariaDB [library]> alter table books add primary (accession_num);
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
'(accession_num)' at line 1
MariaDB [library]> alter table books add primary key (accession_num);
Query OK, 0 rows affected (0.027 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [library]> alter table issue add constraint FK_ASNO foreign


key(accession_num) references books(accession_num);
Query OK, 0 rows affected (0.060 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [library]> select book_name, author_name, Student_name, DOI from book


INNER JOIN issue on book.accession_num= issue.accession_num where num_pages >250;
ERROR 1146 (42S02): Table 'library.book' doesn't exist
MariaDB [library]> select book_name, author_name, Student_name, DOI from book
INNER JOIN issue on books.accession_num= issue.accession_num where num_pages >250;
ERROR 1146 (42S02): Table 'library.book' doesn't exist
MariaDB [library]> select book_name, author_name, Student_name, DOI from books
INNER JOIN issue on books.accession_num= issue.accession_num where num_pages >250;
ERROR 1054 (42S22): Unknown column 'Student_name' in 'field list'
MariaDB [library]> select book_name, author_name, Student_num, DOI from books
INNER JOIN issue on books.accession_num= issue.accession_num where num_pages >250;
Empty set (0.001 sec)

MariaDB [library]> select * from books;


+---------------+-----------+-------------+-----------+
| accession_num | book_name | Author_name | num_pages |
+---------------+-----------+-------------+-----------+
| 1 | kirikou | mathieu | 500 |
| 2 | blanche | bean | 100 |
| 3 | tokoos | fally | 1000 |
| 4 | afrique | mopao | 250 |
| 5 | peuple | idriss | 100 |
+---------------+-----------+-------------+-----------+
5 rows in set (0.000 sec)

MariaDB [library]> select * from issue;


Empty set (0.000 sec)

MariaDB [library]> desc issue;


+---------------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------+------+-----+---------+-------+
| student_num | int(10) | YES | | NULL | |
| accession_num | int(10) | YES | MUL | NULL | |
| DOI | date | YES | | NULL | |
+---------------+---------+------+-----+---------+-------+
3 rows in set (0.005 sec)

MariaDB [library]> alter table issue change DOI DOI timestamp();


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 ')' at
line 1
MariaDB [library]> alter table issue change DOI DOI timestamp;
Query OK, 0 rows affected (0.056 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [library]> insert into issue values (1,1,now()), (2,3, now());


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

MariaDB [library]> insert into issue values (3,2,now()), (4,4, now()), (5,
5,now());
Query OK, 3 rows affected (0.003 sec)
Records: 3 Duplicates: 0 Warnings: 0

MariaDB [library]> desc books;


+---------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| accession_num | int(10) | NO | PRI | NULL | |
| book_name | varchar(100) | YES | | NULL | |
| Author_name | varchar(100) | YES | | NULL | |
| num_pages | int(7) | YES | | NULL | |
+---------------+--------------+------+-----+---------+-------+
4 rows in set (0.005 sec)

MariaDB [library]> desc issue;


+---------------+-----------+------+-----+---------------------
+-------------------------------+
| Field | Type | Null | Key | Default | Extra
|
+---------------+-----------+------+-----+---------------------
+-------------------------------+
| student_num | int(10) | YES | | NULL |
|
| accession_num | int(10) | YES | MUL | NULL |
|
| DOI | timestamp | NO | | current_timestamp() | on update
current_timestamp() |
+---------------+-----------+------+-----+---------------------
+-------------------------------+
3 rows in set (0.00sec)
->
-> [library]>
->
->
->
-> ;
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 'sec)'
at line 1
MariaDB [library]>
MariaDB [library]> select book_name, Author_name,student_num, DOI INNER JOIN issue
on books.accession_num=issue.accession_num where num_pages >250;
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 'INNER
JOIN issue on books.accession_num=issue.accession_num where num_pages >250' at line
1
MariaDB [library]> select book_name, Author_name,student_num, DOI from books INNER
JOIN issue on books.accession_num=issue.accession_num where num_pages >250;
+-----------+-------------+-------------+---------------------+
| book_name | Author_name | student_num | DOI |
+-----------+-------------+-------------+---------------------+
| kirikou | mathieu | 1 | 2023-12-08 16:32:14 |
| tokoos | fally | 2 | 2023-12-08 16:32:14 |
+-----------+-------------+-------------+---------------------+
2 rows in set (0.002 sec)

MariaDB [library]> select book_name, accession_num,DOI from books INNER JOIN issue
on books.accession_num= issue.accession_num;
ERROR 1052 (23000): Column 'accession_num' in field list is ambiguous
MariaDB [library]> select book_name, accession_num, DOI from books INNER JOIN
issue;
ERROR 1052 (23000): Column 'accession_num' in field list is ambiguous
MariaDB [library]>
MariaDB [library]> select book_name, accession_num,DOI from books OUTER JOIN issue
on books.accession_num= issue.accession_num;
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 'OUTER
JOIN issue on books.accession_num= issue.accession_num' at line 1
MariaDB [library]> SELECT Customers.CustomerName, Orders.OrderID
-> FROM Customers
-> FULL OUTER JOIN Orders ON Customers.CustomerID=Orders.CustomerID
-> ORDER BY Customers.CustomerName;
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 'OUTER
JOIN Orders ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customer...' at line 3
MariaDB [library]> select books.book_name, books.accession_num, issue.DOI from
books full outer join orders on books.accession_num = issue.accession_num;
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 'outer
join orders on books.accession_num = issue.accession_num' at line 1
MariaDB [library]> select books.book_name, books.accession_num, issue.DOI from
books full outer joinissue on books.accession_num = issue.accession_num;
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 'outer
join issue on books.accession_num = issue.accession_num' at line 1
MariaDB [library]> select books.book_name, books.accession_num, issue.DOI from
books outer join issue on books.accession_num = issue.accession_num;
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 'outer
join issue on books.accession_num = issue.accession_num' at line 1
MariaDB [library]> select book_name, accession_num, DOI from books outer join issue
on books.accession_num = issue.accession_num;
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 'outer
join issue on books.accession_num = issue.accession_num' at line 1
MariaDB [library]> select books.book_name, books.accession_num, issue.DOI from
books inner join issue on books.accession_num = issue.accession_num;
+-----------+---------------+---------------------+
| book_name | accession_num | DOI |
+-----------+---------------+---------------------+
| kirikou | 1 | 2023-12-08 16:32:14 |
| tokoos | 3 | 2023-12-08 16:32:14 |
| blanche | 2 | 2023-12-08 16:33:10 |
| afrique | 4 | 2023-12-08 16:33:10 |
| peuple | 5 | 2023-12-08 16:33:10 |
+-----------+---------------+---------------------+
5 rows in set (0.001 sec)

MariaDB [library]> select book_name, author_name, num_pages from books where


num_pages> AVG (num_page);
ERROR 1111 (HY000): Invalid use of group function
MariaDB [library]> select book_name, author_name, AVG(num_pages) from books;
+-----------+-------------+----------------+
| book_name | author_name | AVG(num_pages) |
+-----------+-------------+----------------+
| kirikou | mathieu | 390.0000 |
+-----------+-------------+----------------+
1 row in set (0.002 sec)

MariaDB [library]> select * from books;


+---------------+-----------+-------------+-----------+
| accession_num | book_name | Author_name | num_pages |
+---------------+-----------+-------------+-----------+
| 1 | kirikou | mathieu | 500 |
| 2 | blanche | bean | 100 |
| 3 | tokoos | fally | 1000 |
| 4 | afrique | mopao | 250 |
| 5 | peuple | idriss | 100 |
+---------------+-----------+-------------+-----------+
5 rows in set (0.001 sec)

MariaDB [library]> select book_name, author_name, AVG(num_pages) from books where


num_pages> AVG();
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 ')' at
line 1
MariaDB [library]> select book_name, author_name, AVG(num_pages) from books where
num_pages> AVG(num_pages);
ERROR 1111 (HY000): Invalid use of group function
MariaDB [library]> select book_name, author_name, AVG(num_pages) AS average_pages
from books where num_pages> average_pages;
ERROR 1054 (42S22): Unknown column 'average_pages' in 'where clause'
MariaDB [library]> select book_name, author_name, AVG(num_pages) AS [average_pages]
from books where num_pages> average_pages;
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
'[average_pages] from books where num_pages> average_pages' at line 1
MariaDB [library]> select book_name, author_name, num_pages from books where
num_pages> (select AVG(num_pages) from books);
+-----------+-------------+-----------+
| book_name | author_name | num_pages |
+-----------+-------------+-----------+
| kirikou | mathieu | 500 |
| tokoos | fally | 1000 |
+-----------+-------------+-----------+
2 rows in set (0.001 sec)

MariaDB [library]> select author_name, num_pages from books ORDER BY num_pages


DESC;
+-------------+-----------+
| author_name | num_pages |
+-------------+-----------+
| fally | 1000 |
| mathieu | 500 |
| mopao | 250 |
| bean | 100 |
| idriss | 100 |
+-------------+-----------+
5 rows in set (0.001 sec)

MariaDB [library]> se

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