Prepare for your Next Interview
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,...
|
|||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
|||
|
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.. |
| Sponsored Links |
|
|||
|
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 ) |
| The Following User Says Thank You to krishnaindia2007 For This Useful Post: | ||
| Sponsored Links |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| 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 |