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

The Archive Base Latest Questions

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

I have to select requests that i want to combine using UNION : Table

  • 0

I have to select requests that i want to combine using UNION :

Table 1 : which is a join between Table_a, table_b and table_c

id_table_a   desc_table_a   table_b.id_user  table_c.field
-----------------------------------------------------------
1            desc1            1                 field1
2            desc2            2                 field2
3            desc3            3                 field3

Table 2 : which is also a join between Table_a, table_b and table_c but it has these columns:

id_table_a   desc_table_a   table_c.id_user  table_c.field
-----------------------------------------------------------
4            desc4            4                 field4
5            desc5            5                 field8
9            desc9            6                 field9

the difference between the two is that in Table1 we have table_b.id_user and table two
table_c.id_user instead .

Combined Table

  id_table_a   desc_table_a     id_user  table_c.field
    -----------------------------------------------------------
    1            desc1            1                 field1
    2            desc2            2                 field2
    3            desc3            3                 field3
    4            desc4            4                 field4
    5            desc5            5                 field5
    9            desc9            6                 field6

I already have the join requests working but doing union between the two gives me

ORA-01790 expression must have same datatype as corresponding expression

which make sense because the two columns are not the same .

Im using zend_Db’s join and union for this .

So how can i tackle this to get the result ?

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-28T13:48:25+00:00Added an answer on May 28, 2026 at 1:48 pm

    Are the results above the same as the sequence of columns in your table? because oracle is strict in column orders. this example below produces an error:

    create table test1_1790 (
    col_a varchar2(30),
    col_b number,
    col_c date);
    
    create table test2_1790 (
    col_a varchar2(30),
    col_c date,
    col_b number);
    
    select * from test1_1790
    union all
    select * from test2_1790;
    

    ORA-01790: expression must have same datatype as corresponding expression

    As you see the root cause of the error is in the mismatching column ordering that is implied by the use of * as column list specifier. This type of errors can be easily avoided by entering the column list explicitly:

    select col_a, col_b, col_c from test1_1790
    union all
    select col_a, col_b, col_c from test2_1790;
    

    A more frequent scenario for this error is when you inadvertently swap (or shift) two or more columns in the SELECT list:

    select col_a, col_b, col_c from test1_1790
    union all
    select col_a, col_c, col_b from test2_1790;
    

    OR if the above does not solve your problem, how about creating an ALIAS in the columns
    like this: (the query is not the same as yours but the point here is how to add alias in the column.)

    SELECT id_table_a, 
           desc_table_a, 
           table_b.id_user as iUserID, 
           table_c.field as iField
    UNION
    SELECT id_table_a, 
           desc_table_a, 
           table_c.id_user as iUserID, 
           table_c.field as iField
    

    hope this helps.

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

Sidebar

Related Questions

Let's say I have SELECT name FROM table which gives me something like foo
Here's what I want to achieve, I have a select box that loads in
I'm using django and have a page of search results that I want to
I have a query: SELECT ID FROM requests WHERE date <operator> <expression> I need
I have a table. In this table have select element. How can I find
I have a select query that currently produces the following results: Description Code Price
I have a form for a nested resource (Client :has_many Workouts) that I want
using mysql and php, I have two tables, I'm french so the table names
I'm using MVC3 with C# code. I have a table in my SQL Server
I have a simple view that I want to respond to both ajax and

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.