Geeks Talk

Prepare for your Next Interview




updating records

This is a discussion on updating records within the SQL forums, part of the Databases category; i have to update column .there is one to many relationship between two tables.and i am trying to do this .. update line set passcode= "(select mdn from line l,...


Go Back   Geeks Talk > Databases > SQL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 05-21-2008
Junior Member
 
Join Date: May 2008
Posts: 12
Thanks: 3
Thanked 1 Time in 1 Post
AnjaliWatane is on a distinguished road
updating records

i have to update column .there is one to many relationship between two tables.and i am trying to do this ..

update line set passcode= "(select mdn from line l,line_esn le where l.line_id=le.line_id )"

passcode value is last 4 digit of mdn. mdn is 10 digit number.so how do i substring the mdn.likemdn.substring(6,10) .should i have to use function..
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-22-2008
Expert Member
 
Join Date: Sep 2007
Location: tirupathi
Posts: 570
Thanks: 22
Thanked 51 Times in 50 Posts
krishnaindia2007 is on a distinguished road
Re: updating records

Use substr as follows

select substr('1234567890',7,4) from dual
OUPUT
7890

update line set passcode= (select substr(mdn,7,4) from line l,line_esn le where l.line_id=le.line_id )

Here you are using = .

If there is a chance to return more than one row then use distinct keyword in the subquery.

SELECT DISTINCT SUBSTR(MDN,7,4) from line l,line_esn le where l.line_id=le.line_id )
Reply With Quote
The Following User Says Thank You to krishnaindia2007 For This Useful Post:
Sponsored Links
Reply

  Geeks Talk > Databases > SQL


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Updating a View amitkannan SQL 5 01-26-2008 01:42 AM
ORA-01722 Error in updating records sriram_tvs Oracle 2 12-31-2007 02:08 AM
Inserting instead of updating krishnaindia2007 Oracle 4 10-15-2007 07:38 AM
Cyclic Updating JobHelper Oracle 2 10-13-2007 04:06 AM
Updating Java version Geek_Guest Java 1 04-16-2007 08:13 AM


All times are GMT -4. The time now is 07:03 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved