Results 1 to 3 of 3

Thread: updating records

  1. #1
    Junior Member
    Join Date
    May 2008
    Answers
    9

    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..


  2. #2
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    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 )


  3. #3

    Re: updating records

    try this

    select substr(mdn,-4) from ....

    It will give the last four digits


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact