Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General »

Como hacer un DISTINTC de 3 tablas

Estas en el tema de Como hacer un DISTINTC de 3 tablas en el foro de Bases de Datos General en Foros del Web. Hola maestros necesito el query para: Hacer un DISTINCT de 3 tablas en las que hay un campo llamado Nombre y quiero que me muestre ...
  #1 (permalink)  
Antiguo 29/12/2004, 11:08
Avatar de kco
kco
 
Fecha de Ingreso: septiembre-2001
Mensajes: 249
Antigüedad: 22 años, 7 meses
Puntos: 0
Como hacer un DISTINTC de 3 tablas

Hola maestros necesito el query para:

Hacer un DISTINCT de 3 tablas en las que hay un campo llamado Nombre y quiero que me muestre todos los Nombres sin repetirse ya que puede estar Miguel en todas (y repetido varias veces) y solo quiero que me lo muestre 1 vez

Se que con MySQL se puede no quiero liar la cosa metiendo el distint de cada tabla en un array y despues con PHP ordenar y coger uno de cada quiero aprender ha hacerlo correctamente.

Seria parecido a esto pero a mi no me funciona

$Query = Select DISTINCT (tabla1.Nombre), DISTINTC (tabla2.Nombre), DISTINTC (tabla3.Nombre) from tabla1, tabla2, tabla3

Asi no funciona PLEASE ayuda

Muchas gracias y un abrazo de PHPero+
kco
__________________
"No tengas miedo de ir despacio, teme quedarte quieto."
  #2 (permalink)  
Antiguo 29/12/2004, 11:54
Avatar de Keikai  
Fecha de Ingreso: diciembre-2004
Ubicación: Chiapas
Mensajes: 9
Antigüedad: 19 años, 4 meses
Puntos: 0
Información datos...

Puedo intentar ayudarte con eso, pero para ello necesito que me envíes las tablas involucradas en la consulta con los datos completos de cada una...
ya sea en un txt o .sql..
OK???

en cuanto las envies procuraré resolverlo...
  #3 (permalink)  
Antiguo 29/12/2004, 12:14
 
Fecha de Ingreso: mayo-2004
Ubicación: Managua, Nicaragua
Mensajes: 281
Antigüedad: 20 años
Puntos: 0
Creo que talvez no es necesario utilizar el comando DISTINTC, te recomiendo que trabajes con tablas relacionales por Ejemplo Mysql e InnoBD y que pongas como parámetos en Where el posible valor único a buscar.
__________________
Julio Hernández
  #4 (permalink)  
Antiguo 29/12/2004, 13:01
Avatar de kco
kco
 
Fecha de Ingreso: septiembre-2001
Mensajes: 249
Antigüedad: 22 años, 7 meses
Puntos: 0
Muchas Gracias

Necesito mostrar los distintos (sin repetir) Autores de estas tres tablas

# Estructura de tabla para tabla `colecciones`
#

CREATE TABLE colecciones (
Indice int(11) NOT NULL auto_increment,
Tipo text NOT NULL,
Num_Imagenes int(3) NOT NULL default '0',
Referencia text NOT NULL,
Tamano text NOT NULL,
For_Original text NOT NULL,
For_Original_EN text NOT NULL,
Titulo text NOT NULL,
Titulo_EN text NOT NULL,
Autor text NOT NULL,
Autor_EN text NOT NULL,
Descripcion text NOT NULL,
Descripcion_EN text NOT NULL,
Precio text NOT NULL,
Precio_EN text NOT NULL,
Panoramica text NOT NULL,
Portada text NOT NULL,
Estilo text NOT NULL,
PDF text NOT NULL,
KEY Indice (Indice)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Estructura de tabla para tabla `imagenes`
#

CREATE TABLE imagenes (
Indice tinyint(11) NOT NULL auto_increment,
Referencia text NOT NULL,
Titulo text NOT NULL,
Autor text NOT NULL,
Lugar text NOT NULL,
Descripcion text NOT NULL,
Palabras_Clave text NOT NULL,
Coleccion text NOT NULL,
Thumbail text NOT NULL,
Imagen_Muestra text NOT NULL,
Web text NOT NULL,
A1 text NOT NULL,
A2 text NOT NULL,
A3 text NOT NULL,
A4 text NOT NULL,
A5 text NOT NULL,
A6 text NOT NULL,
Categoria text NOT NULL,
Subcategoria text NOT NULL,
Titulo_EN text NOT NULL,
Autor_EN text NOT NULL,
Lugar_EN text NOT NULL,
Descripcion_EN text NOT NULL,
Palabras_Clave_EN text NOT NULL,
Categoria_EN text NOT NULL,
Subcategoria_EN text NOT NULL,
Derechos text NOT NULL,
For_Original text NOT NULL,
For_Original_EN text NOT NULL,
Color text NOT NULL,
KEY Id (Indice)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Estructura de tabla para tabla `videos`
#

CREATE TABLE videos (
Indice tinyint(11) NOT NULL auto_increment,
Referencia text NOT NULL,
Titulo text NOT NULL,
Autor text NOT NULL,
Lugar text NOT NULL,
Descripcion text NOT NULL,
Palabras_Clave text NOT NULL,
Coleccion text NOT NULL,
Thumbail text NOT NULL,
Video_Muestra text NOT NULL,
Med_NTSC text NOT NULL,
Hi_NTSC text NOT NULL,
Med_PAL text NOT NULL,
Hi_PAL text NOT NULL,
Categoria text NOT NULL,
Subcategoria text NOT NULL,
Titulo_EN text NOT NULL,
Autor_EN text NOT NULL,
Lugar_EN text NOT NULL,
Descripcion_EN text NOT NULL,
Palabras_Clave_EN text NOT NULL,
Categoria_EN text NOT NULL,
Subcategoria_EN text NOT NULL,
Derechos text NOT NULL,
For_Original text NOT NULL,
For_Original_EN text NOT NULL,
KEY Id (Indice)
) TYPE=MyISAM;
__________________
"No tengas miedo de ir despacio, teme quedarte quieto."
  #5 (permalink)  
Antiguo 07/01/2005, 13:03
Avatar de kco
kco
 
Fecha de Ingreso: septiembre-2001
Mensajes: 249
Antigüedad: 22 años, 7 meses
Puntos: 0
nadie me echa un cable
__________________
"No tengas miedo de ir despacio, teme quedarte quieto."
  #6 (permalink)  
Antiguo 07/01/2005, 14:01
 
Fecha de Ingreso: febrero-2004
Ubicación: Bogotá, Colombia
Mensajes: 191
Antigüedad: 20 años, 2 meses
Puntos: 1
No se, intente esto:

Select tabla1.nombre, tabla2.nombre, tabla3.nombre FROM tabla1, tabla2, tabla3 WHERE tabla1.nombre=tabla2.nombre AND tabla3.nombre=tabla2.nombre
  #7 (permalink)  
Antiguo 07/01/2005, 14:02
 
Fecha de Ingreso: febrero-2004
Ubicación: Bogotá, Colombia
Mensajes: 191
Antigüedad: 20 años, 2 meses
Puntos: 1
con un GROUP BY tabla1.nombre para q no lops muestre repetidos.
Esto solo le mostrara los nombres q esten en las 3 tablas, es eso lo q necesita?
  #8 (permalink)  
Antiguo 10/01/2005, 14:12
Avatar de kco
kco
 
Fecha de Ingreso: septiembre-2001
Mensajes: 249
Antigüedad: 22 años, 7 meses
Puntos: 0
Muchas gracias Andrecito he estado liado con otra prte del proyecto lo pruebo y te comento

Un PHPero+
kco
__________________
"No tengas miedo de ir despacio, teme quedarte quieto."
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:07.