Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6564995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:02:16+00:00 2026-05-25T14:02:16+00:00

I have a select query that selects files with a thumbnail file attached and

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:02:17+00:00Added an answer on May 25, 2026 at 2:02 pm

    If you have different fields that have different meaning too, you can’t and shouldn’t return them in the same position. You can however ‘fill in the blanks’ by adding null to your fields, like this:

    select id, name, date, null as userid, 'A' as recordtype from table1
    union all
    select id, name, null /*as date*/, userid, 'B' as recordtype from table2 
    

    You can provide an alias for the null in the first select. You can add aliases in the second select for clarity, but it won’t be used. You can even use constant values which you can use to distinguish the record type later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a select query that currently produces the following results: Description Code Price
I have a select query. I want to replace that select query with another
Dear all, I have a select query that currently produces the following results: DoctorName
I have a query that selects rows in a ListView without having a limit.
I have a query that looks like SELECT P.Column1, P.Column2, P.Column3, ... ( SELECT
So I have this query that works perfectly: SELECT users.*, GROUP_CONCAT(categories.category_name) AS categories FROM
I have a query that originally looks like this: select c.Id, c.Name, c.CountryCode, c.CustomerNumber,
I have a query that looks a bit like this: SELECT weekEnd, MAX(timeMonday) FROM
I have a query that makes several calls within a SELECT statement to a
I have a very large query that follows the format below: select ... from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.