Ver Mensaje Individual
  #6 (permalink)  
Antiguo 22/05/2009, 08:18
jurena
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Cáceres
Mensajes: 3.735
Antigüedad: 16 años, 1 mes
Puntos: 300
Respuesta: Obtener datos de una tablas segun un campo

En la dirección recomendada por quimfv, puedes leer esto en los comentarios de Usuarios (pon los datos de tu base, tablas y columna o campo donde corresponde. No lo he probado:
Cita:
User Comments
Posted by James Goatcher on May 27 2008 6:36pm [Delete] [Edit]

A quick way to list your FKs (Foreign Key references) using the KEY_COLUMN_USAGE view:
Código sql:
Ver original
  1. SELECT CONCAT( TABLE_NAME, '.',
  2. column_name, ' -> ',
  3. referenced_table_name, '.',
  4. referenced_column_name ) AS list_of_fks
  5. FROM information_schema.KEY_COLUMN_USAGE
  6. WHERE REFERENCED_TABLE_SCHEMA = (your schema name here)
  7. AND REFERENCED_TABLE_NAME IS NOT NULL AND REFERENCED_COLUMN_NAME = nombrecampo
  8. ORDER BY TABLE_NAME, COLUMN_NAME;
Cita:
This query does assume that the constraints and all referenced and referencing tables are in the same schema.
Le he añadido
AND REFERENCED_COLUMN_NAME = nombrecampo

Haz algunas pruebas

Última edición por jurena; 22/05/2009 a las 08:25