mysql> select current_date(); +----------------+ | current_date() | +----------------+ | 2015-10-24 | +----------------+ 1 row in set (0.00 sec) mysql> select year (current_date()); +-----------------------+ | year (current_date()) | +-----------------------+ | 2015 | +-----------------------+ 1 row in set (0.00 sec) mysql> select month (current_date()); +------------------------+ | month (current_date()) | +------------------------+ | 10 | +------------------------+ 1 row in set (0.00 sec) mysql> select day (current_date()); +----------------------+ | day (current_date()) | +----------------------+ | 24 | +----------------------+ 1 row in set (0.01 sec) mysql> select date_add(current_date(),interval 15 day); +------------------------------------------+ | date_add(current_date(),interval 15 day) | +------------------------------------------+ | 2015-11-08 | +------------------------------------------+ 1 row in set (0.02 sec) mysql> select date_add(current_date(),interval 30 day); +------------------------------------------+ | date_add(current_date(),interval 30 day) | +------------------------------------------+ | 2015-11-23 | +------------------------------------------+ 1 row in set (0.00 sec) mysql> select date_add(current_date(),interval 45 day); +------------------------------------------+ | date_add(current_date(),interval 45 day) | +------------------------------------------+ | 2015-12-08 | +------------------------------------------+ 1 row in set (0.00 sec) mysql> select datediff (current_date(),'1983-07-16'); +----------------------------------------+ | datediff (current_date(),'1983-07-16') | +----------------------------------------+ | 11788 | +----------------------------------------+ 1 row in set (0.03 sec) mysql> select nombre, year(current_date()) - year(nacimiento) from ejercicio; +-------------------+-----------------------------------------+ | nombre | year(current_date()) - year(nacimiento) | +-------------------+-----------------------------------------+ | eder pulgar | 55 | | juan carlos serpa | 33 | | mariana gonzales | 33 | | yoreida maria | 2015 | | angel cuadrado | 49 | | jorge fuentes | 35 | | angela ruiz | 38 | | carlota sonora | 30 | +-------------------+-----------------------------------------+ 8 rows in set (0.00 sec) mysql> select nombre, year(current_date()) - year(nacimiento) 'edad' from ejercicio; +-------------------+------+ | nombre | edad | +-------------------+------+ | eder pulgar | 55 | | juan carlos serpa | 33 | | mariana gonzales | 33 | | yoreida maria | 2015 | | angel cuadrado | 49 | | jorge fuentes | 35 | | angela ruiz | 38 | | carlota sonora | 30 | +-------------------+------+ 8 rows in set (0.00 sec) mysql> select nombre from ejercicio where sexo='mujer' and nombre like '%a'; +----------------+ | nombre | +----------------+ | yoreida maria | | carlota sonora | +----------------+ 2 rows in set (0.05 sec) mysql> select count(*)from ejercicio where sexo='mujer' and nombre like '%a'; +----------+ | count(*) | +----------+ | 2 | +----------+ 1 row in set (0.05 sec) mysql> select count(*)from ejercicio where year(nacimiento) between '1960' and '1969; '> \c '> ; '> €ukasfgjdas;; '> zf€jklgb€zsdflnkv;;;; '> (); '> \c '> /c '> select count(*)from ejercicio where year(nacimiento) between '1960' and '1969;; 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 '1960' and '1969' at line 1 ERROR: No query specified mysql> select count(*)from ejercicio where year(nacimiento) between '1960' and '1969'; +----------+ | count(*) | +----------+ | 2 | +----------+ 1 row in set (0.03 sec) mysql> select * from ejercicio where year(current_date()) - year(nacimiento) between '28' and '33'; +------------+-------------------+--------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+--------+------------+-------+ | 0028957446 | juan carlos serpa | hombre | 1982-11-25 | 2 | | 0822559966 | mariana gonzales | mujer | 1982-03-24 | 1 | | 9999957446 | carlota sonora | mujer | 1985-11-03 | 4 | +------------+-------------------+--------+------------+-------+ 3 rows in set (0.01 sec) mysql> select sum(hijos) from ejercicio; +------------+ | sum(hijos) | +------------+ | 18 | +------------+ 1 row in set (0.02 sec) mysql> select hijos,count(*) from ejercico group by hijos; ERROR 1146 (42S02): Table 'fechas.ejercico' doesn't exist mysql> select hijos,count (*) from ejercico group by hijos; 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 ejercico group by hijos' at line 1 mysql> select hijos,count(*) from ejercicio group by hijos; +-------+----------+ | hijos | count(*) | +-------+----------+ | 0 | 1 | | 1 | 2 | | 2 | 3 | | 4 | 1 | | 6 | 1 | +-------+----------+ 5 rows in set (0.03 sec) mysql> select count(*)from ejercicio where year(current_date) -year(nacimiento) <=28 and sexo='mujer'; +----------+ | count(*) | +----------+ | 0 | +----------+ 1 row in set (0.00 sec) mysql> select count(*)from ejercicio where year(current_date) -year(nacimiento) <=32 and sexo='mujer'; +----------+ | count(*) | +----------+ | 1 | +----------+ 1 row in set (0.00 sec) mysql> create view ejercicio as select * from ejercicio where nombre like '%a'; ERROR 1050 (42S01): Table 'ejercicio' already exists mysql> create view ejercicio as select * from ejercicio where nombre like '%a'; ERROR 1050 (42S01): Table 'ejercicio' already exists mysql> show tables; +------------------+ | Tables_in_fechas | +------------------+ | ejercicio | +------------------+ 1 row in set (0.00 sec) mysql> create view ejercicios as select * from ejercicio where nombre like '%a'; Query OK, 0 rows affected (0.08 sec) mysql> show tables; +------------------+ | Tables_in_fechas | +------------------+ | ejercicio | | ejercicios | +------------------+ 2 rows in set (0.00 sec) mysql> descreibe ejercicios; 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 'descreibe ejercicios' at line 1 mysql> describe ejercicios; +------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+----------+------+-----+---------+-------+ | codigo | char(10) | NO | | NULL | | | nombre | char(30) | YES | | NULL | | | sexo | char(10) | YES | | NULL | | | nacimiento | date | YES | | NULL | | | hijos | char(2) | YES | | NULL | | +------------+----------+------+-----+---------+-------+ 5 rows in set (0.08 sec) mysql> select * from ejercicios; +------------+-------------------+--------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+--------+------------+-------+ | 0028957446 | juan carlos serpa | hombre | 1982-11-25 | 2 | | 1188996633 | yoreida maria | mujer | 0000-00-00 | 2 | | 9999957446 | carlota sonora | mujer | 1985-11-03 | 4 | +------------+-------------------+--------+------------+-------+ 3 rows in set (0.02 sec) mysql> create view ejerciciosexo as select * fom ejercicio where sexo= 'hombre'; 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 'fom ejercicio where sexo= 'hombre'' at line 1 mysql> create view ejerciciosexo as select * from ejercicio where sexo= 'hombre'; Query OK, 0 rows affected (0.09 sec) mysql> select * from ejerciciosexo; +------------+-------------------+--------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+--------+------------+-------+ | 0022559966 | eder pulgar | hombre | 1960-02-20 | 6 | | 0028957446 | juan carlos serpa | hombre | 1982-11-25 | 2 | | 22663355 | angel cuadrado | hombre | 1966-05-13 | 0 | | 4488663322 | jorge fuentes | hombre | 1980-06-22 | 2 | +------------+-------------------+--------+------------+-------+ 4 rows in set (0.00 sec) mysql> create view ejerciciosexo as select * from ejercicio where sexo= 'mujer'; ERROR 1050 (42S01): Table 'ejerciciosexo' already exists mysql> create view ejerciciosexos as select * from ejercicio where sexo= 'mujer'; Query OK, 0 rows affected (0.05 sec) mysql> select * from ejerciciosexos; +------------+-------------------+-------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+-------+------------+-------+ | 0822559966 | mariana gonzales | mujer | 1982-03-24 | 1 | | 1188996633 | yoreida maria | mujer | 0000-00-00 | 2 | | 556959966 | angela ruiz | mujer | 1977-11-15 | 1 | | 9999957446 | carlota sonora | mujer | 1985-11-03 | 4 | +------------+-------------------+-------+------------+-------+ 4 rows in set (0.00 sec) mysql> insert into ejercicio(codigo,nombre,sexo,nacimiento,hijos) values('8005129','Alberto Lechona','hombre','1970-03-22','1'); Query OK, 1 row affected (0.03 sec) mysql> show table ejercicio; 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 'ejercicio' at line 1 mysql> describe table ejercicio; 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 'table ejercicio' at line 1 mysql> describe ejercicio; +------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+----------+------+-----+---------+-------+ | codigo | char(10) | NO | PRI | NULL | | | nombre | char(30) | YES | | NULL | | | sexo | char(10) | YES | | NULL | | | nacimiento | date | YES | | NULL | | | hijos | char(2) | YES | | NULL | | +------------+----------+------+-----+---------+-------+ 5 rows in set (0.00 sec) mysql> describe ejercicios; +------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+----------+------+-----+---------+-------+ | codigo | char(10) | NO | | NULL | | | nombre | char(30) | YES | | NULL | | | sexo | char(10) | YES | | NULL | | | nacimiento | date | YES | | NULL | | | hijos | char(2) | YES | | NULL | | +------------+----------+------+-----+---------+-------+ 5 rows in set (0.01 sec) mysql> describe ejerciciosexo; +------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+----------+------+-----+---------+-------+ | codigo | char(10) | NO | | NULL | | | nombre | char(30) | YES | | NULL | | | sexo | char(10) | YES | | NULL | | | nacimiento | date | YES | | NULL | | | hijos | char(2) | YES | | NULL | | +------------+----------+------+-----+---------+-------+ 5 rows in set (0.02 sec) mysql> describe ejerciciosexos; +------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+----------+------+-----+---------+-------+ | codigo | char(10) | NO | | NULL | | | nombre | char(30) | YES | | NULL | | | sexo | char(10) | YES | | NULL | | | nacimiento | date | YES | | NULL | | | hijos | char(2) | YES | | NULL | | +------------+----------+------+-----+---------+-------+ 5 rows in set (0.00 sec) mysql> select * from ejerciciosexos; +------------+-------------------+-------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+-------+------------+-------+ | 0822559966 | mariana gonzales | mujer | 1982-03-24 | 1 | | 1188996633 | yoreida maria | mujer | 0000-00-00 | 2 | | 556959966 | angela ruiz | mujer | 1977-11-15 | 1 | | 9999957446 | carlota sonora | mujer | 1985-11-03 | 4 | +------------+-------------------+-------+------------+-------+ 4 rows in set (0.00 sec) mysql> select * from ejerciciosexo; +------------+-------------------+--------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+--------+------------+-------+ | 0022559966 | eder pulgar | hombre | 1960-02-20 | 6 | | 0028957446 | juan carlos serpa | hombre | 1982-11-25 | 2 | | 22663355 | angel cuadrado | hombre | 1966-05-13 | 0 | | 4488663322 | jorge fuentes | hombre | 1980-06-22 | 2 | | 8005129 | Alberto Lechona | hombre | 1970-03-22 | 1 | +------------+-------------------+--------+------------+-------+ 5 rows in set (0.00 sec) mysql> select * from ejercicios; +------------+-------------------+--------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+--------+------------+-------+ | 0028957446 | juan carlos serpa | hombre | 1982-11-25 | 2 | | 1188996633 | yoreida maria | mujer | 0000-00-00 | 2 | | 8005129 | Alberto Lechona | hombre | 1970-03-22 | 1 | | 9999957446 | carlota sonora | mujer | 1985-11-03 | 4 | +------------+-------------------+--------+------------+-------+ 4 rows in set (0.00 sec) mysql> select * from ejercicio; +------------+-------------------+--------+------------+-------+ | codigo | nombre | sexo | nacimiento | hijos | +------------+-------------------+--------+------------+-------+ | 0022559966 | eder pulgar | hombre | 1960-02-20 | 6 | | 0028957446 | juan carlos serpa | hombre | 1982-11-25 | 2 | | 0822559966 | mariana gonzales | mujer | 1982-03-24 | 1 | | 1188996633 | yoreida maria | mujer | 0000-00-00 | 2 | | 22663355 | angel cuadrado | hombre | 1966-05-13 | 0 | | 4488663322 | jorge fuentes | hombre | 1980-06-22 | 2 | | 556959966 | angela ruiz | mujer | 1977-11-15 | 1 | | 8005129 | Alberto Lechona | hombre | 1970-03-22 | 1 | | 9999957446 | carlota sonora | mujer | 1985-11-03 | 4 | +------------+-------------------+--------+------------+-------+ 9 rows in set (0.00 sec) mysql> drop view ejerciciosexos; Query OK, 0 rows affected (0.00 sec) mysql> exit