The document creates a MySQL table called "tabel_pet" to store information about pets, including name, owner, species, sex, birth date, and death date. It then inserts records for 8 pets and runs queries to select data from the table, including calculating ages of pets based on birth dates.
The document creates a MySQL table called "tabel_pet" to store information about pets, including name, owner, species, sex, birth date, and death date. It then inserts records for 8 pets and runs queries to select data from the table, including calculating ages of pets based on birth dates.
The document creates a MySQL table called "tabel_pet" to store information about pets, including name, owner, species, sex, birth date, and death date. It then inserts records for 8 pets and runs queries to select data from the table, including calculating ages of pets based on birth dates.
varchar(20) ,sex char(1) ,birth date ,death date);
desc tabel_pet;
insert into tabel_pet value('fluffy','harold','cat','f','1993-02-04','');
insert into tabel_pet value('claws','gwen','cat','m','1994-03-17',''); insert into tabel_pet value('buffy','harold','dog','f','1989-05-13',''); insert into tabel_pet value('fang','benny','dog','m','1990-08-27',''); insert into tabel_pet value('bowser','diane','dog','m','1979-08-31','1995-07-29'); insert into tabel_pet value('whistler','gwen','bird','f','1998-09-11',''); insert into tabel_pet value('chirpy','gwen','bird','','1997-12-02',''); insert into tabel_pet value('slim','benny','snake','m','1996-04-29','');
select*from tabel_pet;
select name, birth from tabel_pet;
select name, birth, year('3003-08-19') - year(birth) as age from tabel_pet;
or
select name,birth,curdate(),timestampdiff(year,birth,curdate()) as age from