1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Insert into multiple fields

Discussion in 'SQL PL/SQL' started by ojgonzalezna, Nov 28, 2017.

  1. ojgonzalezna

    ojgonzalezna Starter

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    10
    Location:
    Bogota
    Morning i need help

    I have 3 tables, the first 2 tables already have values, this is the output

    SQL> select * from tblhorario
    2 ;

    IDHORARIO DESCRIPCIONHORARIO
    ---------- -----------------------
    1 L-V Oficina
    2 L-S Oficina
    3 L-S Extendido
    4 L-S Completo
    5 247

    SQL> select * from tblciudad;

    IDCIUDAD NOMBRECIUDAD
    ---------- -----------------------
    1 Bogota
    2 Cali
    3 Medellin
    4 Bucaramanga
    5 Cartagena
    6 Barranquilla
    7 Cucuta

    7 rows selected.

    For the thir table i need to insert data using a mix of sources:

    First from the normal keyboard input, and second a select query that brings me the fileds DESCRIPCIONHORARIO and NOMBRECIUDAD using the respective ID´S from the other 2 tables. I'm an student and i need help with this.

    This is the original query

    INSERT INTO tblLocal(nombreLocal, direccionLocal, telefono1Local, telefono2Local, celularLocal, emailLocal, renta, idHorario, idCiudad)
    VALUES('UTadeoLozano', 'Cra 5 calle 22', '2756456', 'N/A', '3107770900', 'lutadeo@printing.com', 675000, 1, 1)
    ;

    The last numerical values at the and of the clause are meant to come from the two original tables.

    If the solution is a trigger or a stored procedure, please help me



    Thanks for your answers
     
  2. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    739
    Likes Received:
    145
    Trophy Points:
    830
    Location:
    Russian Federation
    Hi.
    You say that there is a student?
    The acquired experience is your future.
    Therefore, for a start try to write a request.

    What is the key for joining tables : tblhorario and tblciudad ?
    If there are difficulties, then we can help.
    Useful links will be:
    insert
    insert from select
     
    Last edited: Nov 28, 2017