Enter password: ***
Welcome to the MySQL monitor. 
Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.51b-community-nt-log MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database productoss1;
Query OK, 1 row affected (0.00 sec)
mysql> use productoss1;
Database changed
mysql> create table productoss(codigo varchar(3),nombre
varchar(30),precio decim
al(6,2),fechaalta date,primary key(codigo));
Query OK, 0 rows affected (0.15 sec)
mysql> insert into productoss
values('a01','afilador'´,'250','200/11/02');
mysql> insert into productoss
values('a01','afilador',250,'2007/11/02');)
Query OK, 1 row affected (0.24 sec)
mysql>
mysql> insert into productoss values('s01','silla
mod.zaz',20,'2007/11/03');
Query OK, 1 row affected (0.00 sec)
mysql> insert into productoss values('s02','silla
mod.xax','25','2007/11/03');
Query OK, 1 row affected (0.00 sec)
mysql> select*from
productoss;
+--------+---------------+--------+------------+
| codigo |
nombre        | precio | fechaalta  |
+--------+---------------+--------+------------+
| a01    | afilador      | 250.00 | 2007-11-02 |
| s01    | silla mod.zaz |  20.00 | 2007-11-03 |
| s02    | silla mod.xax |  25.00 | 2007-11-03 |
+--------+---------------+--------+------------+
3 rows in set (0.02 sec)
mysql> select*from productoss where nombre='afilador';
+--------+----------+--------+------------+
| codigo |
nombre   | precio | fechaalta  |
+--------+----------+--------+------------+
| a01    | afilador | 250.00 | 2007-11-02 |
+--------+----------+--------+------------+
1 row in set (0.04 sec)
mysql> select*from productoss where nombre like 's%';
+--------+---------------+--------+------------+
| codigo |
nombre        | precio | fechaalta  |
+--------+---------------+--------+------------+
| s01    | silla mod.zaz |  20.00 | 2007-11-03 |
| s02    | silla mod.xax |  25.00 | 2007-11-03 |
+--------+---------------+--------+------------+
2 rows in set (0.00 sec)
mysql> select
nombre,precio from productoss where precio>22;
+---------------+--------+
| nombre        | precio |
+---------------+--------+
| afilador      | 250.00 |
| silla mod.xax |  25.00 |
+---------------+--------+
2 rows in set (0.00 sec)
mysql> select avg(precio)from productoss where
left(nombre,5)='silla?;
select avg(precio)from productoss where left(nombre,5)='silla'' at line
1
mysql> select avg(precio) from productoss where
left(nombre,5)='Silla';
+-------------+
| avg(precio) |
+-------------+
|   22.500000 |
+-------------+
1 row in set (0.02 sec)
mysql> alter table productoss add categoria varchar(10);
Query OK, 3 rows affected (0.05 sec)
Records: 3  Duplicates: 0  Warnings: 0
mysql> select*from productoss;
+--------+---------------+--------+------------+-----------+
| codigo |
nombre        | precio | fechaalta  | categoria |
+--------+---------------+--------+------------+-----------+
| a01    | afilador      | 250.00 | 2007-11-02 | NULL      |
| s01    | silla mod.zaz |  20.00 | 2007-11-03 | NULL      |
| s02    | silla mod.xax |  25.00 | 2007-11-03 | NULL      |
+--------+---------------+--------+------------+-----------+
3 rows in set (0.00 sec)
mysql> update productoss set categoria='utensilio';
Query OK, 3 rows affected (0.02 sec)
Rows matched: 3  Changed: 3  Warnings: 0
mysql> update productoss set categoria="silla"where
left(nombre,5)='silla';
Query OK, 2 rows affected (0.03 sec)
Rows matched: 2  Changed: 2  Warnings: 0
mysql> update productoss set categoria="silla"where
left(nombre,5)='Silla';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2  Changed: 0  Warnings: 0
mysql> select distinct categoria from productoss;
+-----------+
| categoria |
+-----------+
| utensilio |
| silla     |
+-----------+
2 rows in set (0.00 sec)
mysql> select categoria,count(*)from productoss group by categoria;
+-----------+----------+
| categoria | count(*) |
+-----------+----------+
| silla     |        2 |
| utensilio |        1 |
+-----------+----------+
2 rows in set (0.00 sec)
mysql>
 
No hay comentarios.:
Publicar un comentario