SlideShare una empresa de Scribd logo
1 de 5
Descargar para leer sin conexión
Inner Join
CREATE DATABASE FARMACIA
USE FARMACIA

create table producto(
cod_pro int identity (1,1)primary key     not null,
fecha_ven_pro smalldatetime not null,
descrip_pro nvarchar(50) not null,
precio_pro nvarchar(50) not null
)

create table personal(
cod_per int identity (1,1)primary key not null,
nombre_per nvarchar (50)not null,
apellido_per nvarchar (50)not null ,
direccion_per nvarchar (50) not null
)

create table cliente (
cod_cli int identity (1,1)primary key ,
nombre_cli nvarchar (50)not null,
apellido_cli nvarchar (50)not null ,
direccion_cli nvarchar (50) not null
)


Con alias
SELECT * FROM PRODUCTO PR INNER JOIN PERSONAL PE
ON PR.cod_pro = PE.cod_per




Sin alias

                                                      teknos
Rodrigo rosas
SELECT * FROM producto INNER JOIN personal
   ON producto.cod_pro = personal.cod_per




RELACIONAMIENTO INTERNO DE ENTIDADES
1ºPrimera forma
SELECT A.descrip_pro,B.nombre_per FROM   producto A, personal B
WHERE A.cod_pro = B.cod_per




2º Segunda Forma
SELECT descrip_pro, nombre_per
FROM producto INNER JOIN personal ON
producto.cod_pro = personal.cod_per




                                                                  teknos
Rodrigo rosas
3ºTercera Forma

Con alias
SELECT a.descrip_pro, b.nombre_per,c.nombre_cli FROM producto a INNER
JOIN personal b
ON a.cod_pro= b.cod_per INNER JOIN cliente c ON c.cod_cli = b.cod_per




Sin alias
SELECT producto.descrip_pro, personal.nombre_per,cliente.nombre_cli
FROM producto INNER JOIN personal
ON producto.cod_pro= personal.cod_per INNER JOIN cliente ON
cliente.cod_cli = personal.cod_per




                                                                 teknos
Rodrigo rosas
PRACTICA TALLER RELACIONAMIENTO INTERNO DE 2 TABLAS SIN USO DE
JOIN’S “solo where” --------HACER----------
SELECT A.cod_pro,descrip_pro,B.nombre_per FROM producto A,personal B
WHERE A.cod_pro=B.cod_per




Visualizar descripción del producto, nombre del personal,
nombre del cliente
SELECT descrip_pro,nombre_per,nombre_cli
      FROM producto,personal,cliente




                                                                 teknos
Rodrigo rosas
USO WHERE Y AND PUEDE, USAR OR
SELECT a.cod_pro, b.nombre_per,c.nombre_cli FROM producto a, personal
b, cliente c
where a.cod_pro=a.cod_pro and a.cod_per=b.cod_per and
a.cod_cli=c.cod_cli




                                                                 teknos
Rodrigo rosas

Más contenido relacionado

Destacado

Annotations of my magazine showing conventions
Annotations of my magazine showing conventions Annotations of my magazine showing conventions
Annotations of my magazine showing conventions teague8200
 
Evaluation - Real Magazine Annotations of Conventions
Evaluation - Real Magazine Annotations of Conventions Evaluation - Real Magazine Annotations of Conventions
Evaluation - Real Magazine Annotations of Conventions teague8200
 
Visual comparison of conventions
Visual comparison of conventions Visual comparison of conventions
Visual comparison of conventions teague8200
 
Cojo272 intro-f09
Cojo272 intro-f09Cojo272 intro-f09
Cojo272 intro-f09johnkpurdy
 
Big Data needs a facelift to cut through the social noise
Big Data needs a facelift to cut through the social noiseBig Data needs a facelift to cut through the social noise
Big Data needs a facelift to cut through the social noiseshivani Khanna
 
Los usuarios me importan
Los usuarios me importanLos usuarios me importan
Los usuarios me importanFlux IT
 
Lesson 12
Lesson 12Lesson 12
Lesson 12cpashke
 
Sistema de información
Sistema de informaciónSistema de información
Sistema de informaciónlilianitapuin
 
Brenda y clau elementos de sistema solar
Brenda y clau elementos de sistema solarBrenda y clau elementos de sistema solar
Brenda y clau elementos de sistema solarmel_videla
 
[Challenge:Future] Employment Opportunities for
[Challenge:Future] Employment Opportunities for [Challenge:Future] Employment Opportunities for
[Challenge:Future] Employment Opportunities for Challenge:Future
 
Aamukatsaus 1.11.2011
Aamukatsaus 1.11.2011Aamukatsaus 1.11.2011
Aamukatsaus 1.11.2011Nordea Bank
 
Step by step by tyler
Step by step by tylerStep by step by tyler
Step by step by tylerTyler1016
 

Destacado (19)

Me llamo
Me llamoMe llamo
Me llamo
 
Annotations of my magazine showing conventions
Annotations of my magazine showing conventions Annotations of my magazine showing conventions
Annotations of my magazine showing conventions
 
Evaluation - Real Magazine Annotations of Conventions
Evaluation - Real Magazine Annotations of Conventions Evaluation - Real Magazine Annotations of Conventions
Evaluation - Real Magazine Annotations of Conventions
 
Visual comparison of conventions
Visual comparison of conventions Visual comparison of conventions
Visual comparison of conventions
 
Cojo272 intro-f09
Cojo272 intro-f09Cojo272 intro-f09
Cojo272 intro-f09
 
Big Data needs a facelift to cut through the social noise
Big Data needs a facelift to cut through the social noiseBig Data needs a facelift to cut through the social noise
Big Data needs a facelift to cut through the social noise
 
Los usuarios me importan
Los usuarios me importanLos usuarios me importan
Los usuarios me importan
 
Marcos Ton Linkedin
Marcos Ton LinkedinMarcos Ton Linkedin
Marcos Ton Linkedin
 
Lesson 12
Lesson 12Lesson 12
Lesson 12
 
Sistema de información
Sistema de informaciónSistema de información
Sistema de información
 
Demand and Supply
Demand and Supply  Demand and Supply
Demand and Supply
 
Brenda y clau elementos de sistema solar
Brenda y clau elementos de sistema solarBrenda y clau elementos de sistema solar
Brenda y clau elementos de sistema solar
 
[Challenge:Future] Employment Opportunities for
[Challenge:Future] Employment Opportunities for [Challenge:Future] Employment Opportunities for
[Challenge:Future] Employment Opportunities for
 
Afv 2011
Afv 2011Afv 2011
Afv 2011
 
Problemas Pós-Greve (EBCT)
Problemas Pós-Greve (EBCT)Problemas Pós-Greve (EBCT)
Problemas Pós-Greve (EBCT)
 
Formato
FormatoFormato
Formato
 
Ewa Development Plan
Ewa Development PlanEwa Development Plan
Ewa Development Plan
 
Aamukatsaus 1.11.2011
Aamukatsaus 1.11.2011Aamukatsaus 1.11.2011
Aamukatsaus 1.11.2011
 
Step by step by tyler
Step by step by tylerStep by step by tyler
Step by step by tyler
 

Joins rodrigo

  • 1. Inner Join CREATE DATABASE FARMACIA USE FARMACIA create table producto( cod_pro int identity (1,1)primary key not null, fecha_ven_pro smalldatetime not null, descrip_pro nvarchar(50) not null, precio_pro nvarchar(50) not null ) create table personal( cod_per int identity (1,1)primary key not null, nombre_per nvarchar (50)not null, apellido_per nvarchar (50)not null , direccion_per nvarchar (50) not null ) create table cliente ( cod_cli int identity (1,1)primary key , nombre_cli nvarchar (50)not null, apellido_cli nvarchar (50)not null , direccion_cli nvarchar (50) not null ) Con alias SELECT * FROM PRODUCTO PR INNER JOIN PERSONAL PE ON PR.cod_pro = PE.cod_per Sin alias teknos Rodrigo rosas
  • 2. SELECT * FROM producto INNER JOIN personal ON producto.cod_pro = personal.cod_per RELACIONAMIENTO INTERNO DE ENTIDADES 1ºPrimera forma SELECT A.descrip_pro,B.nombre_per FROM producto A, personal B WHERE A.cod_pro = B.cod_per 2º Segunda Forma SELECT descrip_pro, nombre_per FROM producto INNER JOIN personal ON producto.cod_pro = personal.cod_per teknos Rodrigo rosas
  • 3. 3ºTercera Forma Con alias SELECT a.descrip_pro, b.nombre_per,c.nombre_cli FROM producto a INNER JOIN personal b ON a.cod_pro= b.cod_per INNER JOIN cliente c ON c.cod_cli = b.cod_per Sin alias SELECT producto.descrip_pro, personal.nombre_per,cliente.nombre_cli FROM producto INNER JOIN personal ON producto.cod_pro= personal.cod_per INNER JOIN cliente ON cliente.cod_cli = personal.cod_per teknos Rodrigo rosas
  • 4. PRACTICA TALLER RELACIONAMIENTO INTERNO DE 2 TABLAS SIN USO DE JOIN’S “solo where” --------HACER---------- SELECT A.cod_pro,descrip_pro,B.nombre_per FROM producto A,personal B WHERE A.cod_pro=B.cod_per Visualizar descripción del producto, nombre del personal, nombre del cliente SELECT descrip_pro,nombre_per,nombre_cli FROM producto,personal,cliente teknos Rodrigo rosas
  • 5. USO WHERE Y AND PUEDE, USAR OR SELECT a.cod_pro, b.nombre_per,c.nombre_cli FROM producto a, personal b, cliente c where a.cod_pro=a.cod_pro and a.cod_per=b.cod_per and a.cod_cli=c.cod_cli teknos Rodrigo rosas