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.
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:
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:
A more frequent scenario for this error is when you inadvertently swap (or shift) two or more columns in the SELECT list:
OR if the above does not solve your problem, how about creating an
ALIASin the columnslike this: (the query is not the same as yours but the point here is how to add alias in the column.)
hope this helps.