web analytics

ORA-01427: single-row subquery returns more than one row

Options

codeling 1599 - 6654
@2016-12-08 22:36:13

The ORA-01427 is a straightforward query error in Oracle. The cause of the error is a subquery returning more than one row of information.

Try  the following SQL statement:

SELECT *

FROM employers

WHERE client_id = (SELECT client_id

         FROM clients

         WHERE clients_name = ‘Walmart’) ;

If more than one instance in the client’s table of the clients_name ‘Walmart’ existed, the following would be prompted:

ORA-01427: single-row subquery returns more than one row

@2016-12-08 23:30:52

You can then correct the statement by utilizing an IN condition, which is used to reduce the need for multiple OR conditions in SELECT statements:

SELECT *

FROM employers

WHERE client_id IN (SELECT client_id

      FROM clients

      WHERE clients_name = ‘Walmart’) ;

 

This will eliminate the ORA-01427 error message from occurring.

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com