473,379 Members | 1,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

single-row subquery returns more than one row

Hi folks,

I have an situation like I have an table named Location where by it stores all
the details of location. In the table I have 2 columns State, city where by I have some duplicate values in the loc table like

for eg:

State City

MH Aurangbad
BH Aurangbad
MP Aurangbad

I need to update the values of the city column with the prefix of state like


State City

MH Aurangbad - MH
BH Aurangbad - BH
MP Aurangbad - MP

I have written an query like

UPDATE LOC
SET CITY = (SELECT CITY || ' - '|| SUBSTR(STATE,1,2)
FROM LOC)
WHERE STATE IN ('MH','BH','MP');


But I am getting an error message like ORA-01427: single-row subquery returns more than one row.

Pls do find an solution for the same.

Arun
Aug 4 '07 #1
4 4202
Update Loc L
Set L.city = (select City||' - '||substr(state,1,2) From Loc L1 Where L.state = L1.state)
Where L.state In ('MH',BH','MP')
Aug 4 '07 #2
Update Loc L
Set L.city = (select City||' - '||substr(state,1,2) From Loc L1 Where L.state = L1.state)
Where L.state In ('MH',BH','MP')
Dear tedlaraghu],

First of all I would like to thank you for helping me out. Since I am new to this SQL I wouls also like you to explain me regarding the code, because you have mentioned 2 aliases for the same table LOC. It's bit confusing.So pls do explain me about the code.

Arun
Aug 5 '07 #3
Dear tedlaraghu],

First of all I would like to thank you for helping me out. Since I am new to this SQL I wouls also like you to explain me regarding the code, because you have mentioned 2 aliases for the same table LOC. It's bit confusing.So pls do explain me about the code.

Arun
Hi,

When I execute the same code I am getting an error messages stating that
ORA-00904: "L"."STATE": invalid identifier. I tried but I am not able to resolve it.
Pls look into this.

Arun
Aug 5 '07 #4
debasisdas
8,127 Expert 4TB
Why not use

Expand|Select|Wrap|Line Numbers
  1. update loc set city = city ||'-'||state;
Aug 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: sinister | last post by:
The examples in the online manual all seem to use double quotes, e.g. at http://us3.php.net/preg_replace Why? (The behavior is different with single quotes, and presumably simpler to...
12
by: Dennis Plöger | last post by:
Hi all! I'm currently having some problems parsing a char array in c++. (And yes, I'm a half-newbie ;-)) Perhaps you can help me with this: #include <iostream> using std::cout; void...
5
by: Joel | last post by:
Hi, I incorporated a function in my code that whenever I use a string variable in an sql statement if the string contains a single quote it will encase it in double quotes else single quotes. ...
9
by: MrSpock | last post by:
1. Create a new Windows Application project. 2. Open the project properties and check "Make single instance application". 3. Build. 4. Go to the release folder and run the application. 5. Try to...
13
by: Kevin Walzer | last post by:
Which of the Windows/Unix package builders for Python applications is capable of creating single-file executables? I'm thinking of: 1. py2exe 2. Mcmillan Installer/PyInstaller 3. cxfreeze ...
11
by: Elmo | last post by:
Hi all! I am not very proud to ask this but here is my problem: string code = "\'13\'" The string code will have to contain following info: '51','52','63','other'... to get certain info...
3
by: Eric Layman | last post by:
Hi, I've saved data into the db by doing a replace() on single quote. Right now on data display on a datagrid, it shows double single quote. How do I make changes during run time of datagrid...
4
by: fniles | last post by:
I am looping thru DataReader and constructing a sql query to insert to another database. When the data type of the field is string I insert the field value using a single quote. When the value of...
2
by: Reporter | last post by:
I got the following example from http://www.evolt.org/article/User_Friendly_Forms_in_PHP/20/60144/index.html : echo '<tr><td>First name:</td><td><input type="text" name="first_name"...
3
by: sklett | last post by:
I suspect the answer might be in one of the words of my subject, but here goes anyway. I'm working on a system that will execute a very long (300+) chain of task objects. Here is some quick...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.