mysql> create table reserva(id int(10) primary key auto_increment, tempo time, data date);
Query OK, 0 rows affected (0.08 sec)
mysql> desc reserva;
+-------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+----------------+
| id | int(10) | NO | PRI | NULL | auto_increment |
| tempo | time | YES | | NULL | |
| data | date | YES | | NULL | |
+-------+---------+------+-----+---------+----------------+
3 rows in set (0.04 sec)
mysql> insert into reserva (tempo,data) values (CURTIME(),CURDATE());
Query OK, 1 row affected (0.00 sec)
mysql> select * from reserva;
+----+----------+------------+
| id | tempo | data |
+----+----------+------------+
| 1 | 17:33:40 | 2012-06-08 |
+----+----------+------------+
1 row in set (0.00 sec)
mysql> select * from reserva where tempo < CURDATE();
Empty set (0.00 sec)
mysql> select * from reserva where tempo > CURDATE();
+----+----------+------------+
| id | tempo | data |
+----+----------+------------+
| 1 | 17:33:40 | 2012-06-08 |
+----+----------+------------+
1 row in set (0.00 sec)
mysql> select * from reserva where data = CURDATE();
+----+----------+------------+
| id | tempo | data |
+----+----------+------------+
| 1 | 17:33:40 | 2012-06-08 |
+----+----------+------------+
1 row in set (0.00 sec)
mysql> select * from reserva where data > CURDATE();
Empty set (0.00 sec)
mysql> select * from reserva where data < CURDATE();
Empty set (0.00 sec)
mysql> insert into reserva (tempo,data) values ('10:33:40','2010-06-10');
Query OK, 1 row affected (0.39 sec)
mysql> insert into reserva (tempo,data) values ('05:43:40','2000-03-10');
Query OK, 1 row affected (0.00 sec)
0 comentários:
Post a Comment