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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:09:50+00:00 2026-06-16T12:09:50+00:00

I want to combine multiple tables into one VIEW . My understanding is that

  • 0

I want to combine multiple tables into one VIEW.
My understanding is that if the number of columns are different we cannot use UNION.
How do I solve this?

I have the following three TABLES:

1.Table Name- Albums

enter image description here

2.Table Name-AlbumPictures

enter image description here

3.Table Name-Stories

enter image description here

I want to have 3 tables as follows:(i can do this part using INNER JOINS- kindly correct me if i am wrong)

For Stories: StoryID,AlbumID,StoryTitle,AlbumCover,Votes

For Albums: AlbumID,AlbumName,AlbumCover,Votes

For Pictures: AlbumPictureID,Votes

I want to merge all the rows retrieved from the above queries into one VIEWand shuffle them. As the number of columns are different in each of the result sets above am I able to combine them into one VIEW?

  • 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-06-16T12:09:51+00:00Added an answer on June 16, 2026 at 12:09 pm

    You can do something like this. All three tables are given similar columns with null values and TableName column is to identify the table which brings the data

    EDIT: I have to say, this is not the right approach. I wanted to show you how to union tables but I think now it is getting ugly when editing it according to your comments.

    --Note: Vote is on all three table, I have selected from Stories
    select s.storyId, a.albumId, s.storyTitle, null albumName, 
           ap.albumCover, s.votes , null albumPictureId, 'stories-albums-albumPics' tableName
    from Stories s join Albums a on s.albumId = a.albumId 
                   join AlbumPictures ap on a.albumid = ap.albumId
    
    UNION ALL 
    select null storyId, a.albumID, null storyTitle, a.albumName,
           ap.albumCover, a.votes, null albumPictureId, 'albums-albumPics' tableName
    from Albums a join AlbumPictures ap on a.albumid = ap.albumId
    
    UNION ALL --use required table here as well  
    select null storyId, null albumId, null storyTitle, null albumName, 
           null albumCover, votes, albumPictureId, 'pictures' tableName 
    from Pictures 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do you combine multiple select count(*) from different table into one return? I
I want to combine multiple tables result count in one result with column wise
I want to combine these two queries into one: mysql_query(INSERT INTO categories (name, parent)
Possible Duplicate: Combine Multiple child rows into one row MYSQL I have following table,
Possible Duplicate: MySQL Results as comma separated list Combine Multiple child rows into one
I'm trying to combine multiple JSON objects into a single one in PHP. I'm
I've always been confused on how to combine multiple MySQL queries into one. I've
I am trying to combine 5 queries into one query so that I do
I want to combine Hadoop based Mahout recommenders with Apache Hive.So that My generated
I want to combine three tables - date, lead and click - in a

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.