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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:41:54+00:00 2026-05-24T13:41:54+00:00

I have data in two tables that I want to query from. Each table

  • 0

I have data in two tables that I want to query from. Each table has a different number of columns, but they both have one column, vID, that I want to use for my query. If I was querying one table, I would use this column in my WHERE clause:

"SELECT * FROM table1 WHERE vID = ?"

And then I would use that cursor for my listAdapter.

The problem is in the same list, I also want to show data from another table:

"SELECT * FROM table2 WHERE vID = ?"

Both tables have day, month, and year values that I want to use in my adapter, and a name column that I want to use.

I have tried UNION, but that returns an error because both tables have a different number of columns.

What should my query look like? Thanks.

  • 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-24T13:41:54+00:00Added an answer on May 24, 2026 at 1:41 pm

    If the columns are indeed the same, you need to specify those in the select to use UNION

    SELECT foo,biz,baz FROM table1 WHERE vID = ?
    UNION
    SELECT foo,biz,baz FROM table2 WHERE vID = ?
    

    The error you’re getting is because the two tables have different columns, you can still UNION them, but you have to specify how to align the two tables if their schema is not identical.

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

Sidebar

Related Questions

I have two tables that I want to fetch data from. Lets call them
I have two tables that contain data from different temperature sensors: Table1 _TimeStamp Temperature
Similar question here but this is slightly different... I have two tables that I
I have two tables users registered_members I want to confirm values from user table
I have two tables. Widgets, which has information about each widget (Color, size, etc);
I have n:m table which links data between two tables: id | category -------------
I have two tables that look as Follows: Person (Table Name) Name1/Phone1/Email1/Address1/Organization1/Notes1 (Fields) Organization
I have a two-dimensional array (of Strings) which make up my data table (of
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two processes one will query other for data.There will be huge amount

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.