web analytics
ORA-01427: single-row subquery returns more than one row Options
codeling
Posted: Thursday, December 8, 2016 10:36:13 PM

Rank:Advanced Member
Groups: Member
Joined: 12/11/2015
Posts: 982
Points: 4134

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

Sponsor
Posted: Thursday, December 8, 2016 10:36:13 PM
 
codeling
Posted: Thursday, December 8, 2016 11:30:52 PM

Rank:Advanced Member
Groups: Member
Joined: 12/11/2015
Posts: 982
Points: 4134

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.

Users browsing this topic
Guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.


© 2018 Digcode.com. All rights reserved.