Ora-01790: expression must have the same data type as the corresponding expression

March 1, 2021 627 point heat 2 people like it 1 comment

Ora-01790: expression must have the same data type as the corresponding expression

1、 It is said on the Internet:

If this kind of error occurs, you should first check whether there are connections in SQL, such as union, Unio, all, and so on. If so, you need to note that the data types of fields with the same name must be the same.

        select a.time from A a union all select b.time from B b where a.name =   b.name;

For example, if the above SQL sentence appears, it should be noted that one of the time fields in a and B may be in date format and the other in string format. In short, the format may not be the same. Be careful.

2、 But I would like to add one more thing

I wrote two SQL, using union all connection.

 select a.name  a.age from  studentTabA  a  union all   select b.name b.age from studentTabB  b

The above statement is not wrong, but if you write it like this, it will still report ora-01790

 select a.age  a.name from  studentTabA  a  union all   select b.name b.age from studentTabB  b

That is, each select statement within the union Must have the same number of columns

Lieye Must have similar data types

At the same time, the The order of columns must be the same

Gcod

If life is just like the first sight, what is the sad autumn wind painting fan

Article review

  • Shopee native

    That's good. Give it a go

    August 7, 2021