..:: MX Studio Fóruns ::..: AJUDAAA select!! - ..:: MX Studio Fóruns ::..

Jump to content

Publicidade




ATENÇÃO

Para evitar posts desnecessários e que não influam para o andamento e desenvolvimento do fórum, clique aqui e leia todas as regras.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

AJUDAAA select!! fazer um select de uma tabela com 2 chaves extrangeiras

#1 User is offline   FuRaCaO 

  • Group: Membros
  • Posts: 1
  • Joined: 24-October 08

Posted 24 October 2008 - 02:05 PM

Ola preciso de uma ajuda na criacao de um select entre 2 tabelas onde tenho uma tabela Partida possui 2 campos time_casa, time_vizitante que sao chaves extrangeiras, e essa tabela eh ligada a uma tabela Time.

Duvida - como faço um select na tabela Partida que eu consiga o nome dos dois times???

segue o dump das 2 tabelas a baixo

Tabela Partida

CREATE TABLE `banco`.`partida` (

`id` int(10) unsigned NOT NULL auto_increment,

`hora` time NOT NULL,

`id_time_casa` int(10) unsigned NOT NULL,

`id_time_visitante` int(10) unsigned NOT NULL,

`resul_casa` int(10) unsigned NOT NULL,

`resul_visitante` int(10) unsigned NOT NULL,

`local` varchar(45) NOT NULL,

`id_rodada` int(10) unsigned NOT NULL,

PRIMARY KEY (`id`),
KEY `id_time_casa` (`id_time_casa`),
KEY `id_time_visitante` (`id_time_visitante`),

KEY `id_rodada` (`id_rodada`),
CONSTRAINT `id_rodada` FOREIGN KEY (`id_rodada`) REFERENCES `rodada` (`id`),

CONSTRAINT `id_time_casa` FOREIGN KEY (`id_time_casa`) REFERENCES `time` (`id`),
CONSTRAINT
`id_time_visitante` FOREIGN KEY (`id_time_visitante`) REFERENCES `time` (`id`)
) ENGINE=InnoDB DEFAULT
CHARSET=latin1;


Tabela Time



CREATE TABLE `banco`.`time` (
`id` int(10) unsigned NOT NULL auto_increment,

`nome` varchar(50) NOT NULL,

`campo` varchar(50) NOT NULL,

`escudo` varchar(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic



Publicidade




2 User(s) are reading this topic
0 membro(s), 2 visitante(s) e 0 membros anônimo(s)