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 116189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:08:19+00:00 2026-05-11T03:08:19+00:00

I am trying to create a view for a UNION of 2 select statements

  • 0

I am trying to create a view for a UNION of 2 select statements that I have created.

The UNION is working fine when executed individually

But the problem is only the 1st part of the UNION is getting executed when I am executing it as a view.

The query I am using is as below

   SELECT DISTINCT   products.pid        AS id,   products.pname      AS name,   products.p_desc     AS description,   products.p_uid      AS userid,   products.p_loc      AS location,   products.isaproduct AS whatisit FROM products UNION SELECT DISTINCT   services.s_id       AS id,   services.s_name     AS name,   services.s_desc     AS description,   services.s_uid      AS userid,   services.s_location AS location,   services.isaservice AS whatisit FROM services 

The above works fine when i execute it separately. But when I use it as a view, it does not give me the results of the services part.

Could someone please help me with 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. 2026-05-11T03:08:19+00:00Added an answer on May 11, 2026 at 3:08 am

    Try this

       SELECT DISTINCT   products.pid        AS id,   products.pname      AS name,   products.p_desc     AS description,   products.p_uid      AS userid,   products.p_loc      AS location,   products.isaproduct AS whatisit FROM products UNION ALL SELECT DISTINCT   services.s_id       AS id,   services.s_name     AS name,   services.s_desc     AS description,   services.s_uid      AS userid,   services.s_location AS location,   services.isaservice AS whatisit FROM services 

    I’m not sure, I tried that with a table on my server and it worked.. I guess it will work for you. Hint the only difference here is that I used ‘union all’ instead of just ‘union’

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

Sidebar

Related Questions

I am trying to create a view in mySQL that gets created or updated
I'm trying to create a view programmatically. The result that i want to have
I'm trying to create a view, and have distilled the problem down to the
I'm trying to add a strongly-typed view to the sample app that's created when
I am trying to create a view that takes the latest of each individual
I'm trying to create a view out of quite a complex select query and
I am trying to create a view with buttons that overlay a scrollview and
I am trying to create a view as follows: CREATE VIEW vw1 AS SELECT
I'm trying to create a view that is backed by a Core Animation layer.
I'm trying to create a View dynamically (on click). Any person have any idea

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.