I have a select query that selects files with a thumbnail file attached and I also need to get those with no thumbnail attached.
My current sql query is
SELECT node.title, node.nid, files.fid, files.filepath,
content_type_mobile_event.field_date_value,
content_type_mobile_event.field_movie_shorts_value,
content_type_mobile_event.field_director_value,
content_type_mobile_event.field_length_value,
content_type_mobile_event.field_movie_type_value,
content_type_mobile_event.field_year_value,
content_type_mobile_event.field_event_type_value,
content_type_mobile_event.field_movie_location_value,
content_type_mobile_event.field_movie_desc_value,
content_type_mobile_event.field_movie_id_value,
content_type_mobile_event.field_movie_thumb_fid,
content_type_mobile_event.field_movie_trailer_url
FROM node, content_type_mobile_event, files
WHERE node.nid=content_type_mobile_event.nid AND
content_type_mobile_event.field_movie_thumb_fid=files.fid
ORDER BY content_type_mobile_event.field_date_value ASC
I need to also get
SELECT node.title, node.nid, content_type_mobile_event.field_date_value,
content_type_mobile_event.field_movie_shorts_value,
content_type_mobile_event.field_director_value,
content_type_mobile_event.field_length_value,
content_type_mobile_event.field_movie_type_value,
content_type_mobile_event.field_year_value,
content_type_mobile_event.field_event_type_value,
content_type_mobile_event.field_movie_location_value,
content_type_mobile_event.field_movie_desc_value,
content_type_mobile_event.field_movie_id_value,
content_type_mobile_event.field_movie_thumb_fid,
content_type_mobile_event.field_movie_trailer_url
FROM node, content_type_mobile_event
WHERE node.nid=content_type_mobile_event.nid AND
content_type_mobile_event.field_movie_thumb_fid!=1
ORDER BY content_type_mobile_event.field_date_value ASC
I would normally just do a
(
SELECT node.title, node.nid, files.fid, files.filepath,
content_type_mobile_event.field_date_value,
content_type_mobile_event.field_movie_shorts_value,
content_type_mobile_event.field_director_value,
content_type_mobile_event.field_length_value,
content_type_mobile_event.field_movie_type_value,
content_type_mobile_event.field_year_value,
content_type_mobile_event.field_event_type_value,
content_type_mobile_event.field_movie_location_value,
content_type_mobile_event.field_movie_desc_value,
content_type_mobile_event.field_movie_id_value,
content_type_mobile_event.field_movie_thumb_fid,
content_type_mobile_event.field_movie_trailer_url
FROM node, content_type_mobile_event, files
WHERE node.nid=content_type_mobile_event.nid AND
content_type_mobile_event.field_movie_thumb_fid=files.fid
ORDER BY content_type_mobile_event.field_date_value ASC
)
UNION
(
SELECT node.title, node.nid, content_type_mobile_event.field_date_value,
content_type_mobile_event.field_movie_shorts_value,
content_type_mobile_event.field_director_value,
content_type_mobile_event.field_length_value,
content_type_mobile_event.field_movie_type_value,
content_type_mobile_event.field_year_value,
content_type_mobile_event.field_event_type_value,
content_type_mobile_event.field_movie_location_value,
content_type_mobile_event.field_movie_desc_value,
content_type_mobile_event.field_movie_id_value,
content_type_mobile_event.field_movie_thumb_fid,
content_type_mobile_event.field_movie_trailer_url
FROM node, content_type_mobile_event
WHERE node.nid=content_type_mobile_event.nid AND
content_type_mobile_event.field_movie_thumb_fid!=1
ORDER BY content_type_mobile_event.field_date_value ASC
)
But the problem is the second one has a different set of columns (minus the files.* part)
I cannot for the life of me figure out how to do this.