21/04/2008, 09:37
|
Colaborador | | Fecha de Ingreso: marzo-2008 Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 9 meses Puntos: 574 | |
Re: obtener datos que no estan en una tabla Uff, dificil de seguirte, pero
Código:
SELECT recruiters.first_name,
recruiters.last_name,
talents.fr_id,
talents_events.talent_id,
talents_events.event_id,
events.description,
management.fr_id AS agent_frid
FROM recruiters JOIN talents
ON talents.prereg_id = recruiters.id
JOIN talents_events
ON talents_events.talent_id = recruiters.id
JOIN EVENTS
ON events.id = talents_events.event_id
JOIN events_locations_agents
ON events_locations_agents.event_id = events.id
JOIN management
ON management.id = events_locations_agents.agent_fr_id
JOIN users
ON users.id = management.user_id
WHERE recruiters.id = talents_events.talent_id
AND talents_events.complete =1
AND events.id NOT
IN (SELECT event_id
FROM comments)
AND talents_events.talent_id NOT
IN (SELECT talent_id
FROM comments)
AND users.level =2
Las condiciones en rojo son redundantes, puedes eliminar la del where.
Luego intenta esto:
Código:
SELECT recruiters.first_name,
recruiters.last_name,
talents.fr_id,
talents_events.talent_id,
talents_events.event_id,
events.description,
management.fr_id AS agent_frid
FROM recruiters JOIN talents
ON talents.prereg_id = recruiters.id
JOIN talents_events
ON talents_events.talent_id = recruiters.id
JOIN EVENTS
ON events.id = talents_events.event_id
JOIN events_locations_agents
ON events_locations_agents.event_id = events.id
JOIN management
ON management.id = events_locations_agents.agent_fr_id
JOIN users
ON users.id = management.user_id
WHERE talents_events.complete =1
AND users.level =2
AND (events.id NOT
IN (SELECT event_id
FROM comments)
OR talents_events.talent_id NOT
IN (SELECT talent_id
FROM comments)) No estoy seguro de si he interpretado bien lo que necesitas pero por intentarlo no perderas nada.
Quim
Última edición por quimfv; 21/04/2008 a las 10:32 |