Update Query returine more then one row in Oracle

Posted on 2014-04-21
Last Modified: 2014-04-25
I need update all values on one table as T where there exist certain condition on other table.

I know this query is wrong but how do I get it to work in Oracle update statement if the select statement between () returns a value

update sample s set s.L_INVOICE_FLAG  = 'T' where (s.project like (select from project p inner join sample s on = s.project where p.closed = 'T' and p.status = 'V'))
Question by:gilnari
  • 2
LVL 77

Accepted Solution

slightwv (䄆 Netminder) earned 500 total points
ID: 40013720
Not sure I follow the logic but try IN.

...  where (s.project like (select ...
...  where (s.project in (select ...
LVL 48

Expert Comment

ID: 40013987
and then also remove the inner join as it won't be required
UPDATE sample s
WHERE s.project IN (
		FROM project p
		WHERE p.closed = 'T' AND p.STATUS = 'V'

Open in new window


Expert Comment

ID: 40014273
... where (s.project like ...
... on = s.project  ...
are duplicated.
So it should be like this:
update sample s set s.L_INVOICE_FLAG  = 'T' where s.project in (select from project p where p.closed = 'T' and p.status = 'V')
you can not use 'like' against sub-query.
LVL 48

Expert Comment

ID: 40014920
did I not propose exactly the same query?

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
exp/imp 25 101
How to Gracefuly recover in Racle stored procedure 1 47
pivot rows to columns 1 45
capture vmstat info and insert it into an oracle table 31 61
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question