Images

octubre 11 de 2017

Enlazar tablas

Vamos a seguir con el ejemplo de ayer para ver como podemos enlazar tablas usando el comando joins de select.
Teníamos la base de datos biblioteca. Para los que justo os incorporáis al curso, la podéis crear y seleccionar con:
1create database biblioteca;
2use biblioteca;
Volvemos a crear la tabla libros, pero esta vez incluimos el campo editorial:
1create table libros(
2       libro_id int unsigned auto_increment,
3       titulo varchar(50) not null,
4       autor varchar(30) not null default 'Desconocido',
5       codigo_editorial int unsigned not null,
6       cantidad smallint unsigned default 0,
7      primary key (libro_id)
8 );

Código para crear la tabla desde phpmyadmin:

create database  nombre;
use nombre;
 CREATE TABLE `tabla` (
  `id` int(111) NOT NULL auto_increment,
  `telefono` varchar(100) NOT NULL,
  `siono` varchar(100)   NOT NULL,
  `fecha` date(100)  NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 

0 comentarios: