/* Intersecção em MySql com INNER JOIN */ /* Criando banco de exemplo */ CREATE DATABASE teste; USE teste; /* Criando tabelas de exemplo */ CREATE TABLE tabela1 ( id INT(11) PRIMARY KEY ); CREATE TABLE tabela2 ( id INT(11) PRIMARY KEY ); CREATE TABLE tabela3 ( id INT(11) PRIMARY KEY ); INSERT INTO tabela1 VALUES (1); INSERT INTO tabela1 VALUES (2); INSERT INTO tabela1 VALUES (3); INSERT INTO tabela2 VALUES (2); INSERT INTO tabela2 VALUES (3); INSERT INTO tabela2 VALUES (4); INSERT INTO tabela3 VALUES(3); INSERT INTO tabela3 VALUES(4); INSERT INTO tabela3 VALUES(5); /* Assim temos estas tabelas: */ /* tabela1 +----+ | id | +----+ | 1 | | 2 | | 3 | +----+ tabela2 +----+ | id | +----+ | 2 | | 3 | | 4 | +----+ tabela3 +----+ | id | +----+ | 3 | | 4 | | 5 | +----+ */ SELECT a.id FROM tabela1 a INNER JOIN tabela2 b ON (a.id = b.id) INNER JOIN tabela3 c ON (a.id = c.id) ORDER BY a.id /* +----+ | id | +----+ | 3 | +----+ */
- Fórum WMO
- → Viewing Profile: Tópicos: spambot
Community Stats
- Group Usuários
- Active Posts 4
- Profile Views 914
- Member Title Novato no fórum
- Age Age Unknown
- Birthday Birthday Unknown
-
Sexo
Não informado
1
Neutral
User Tools
Friends
spambot hasn't added any friends yet.
Latest Visitors
-
Guest
04/11/2007, 02:37
Topics I've Started
Intersecção Em Mysql Com Inner Join
03/01/2007, 15:08
- Fórum WMO
- → Viewing Profile: Tópicos: spambot
- Privacy Policy
- Regras ·