Error in table update from select

Discussion in 'MySQL' started by piropeator, May 20, 2016.

  1. #1
    I want to run this code, but I get this message:" #1052 - Column 'name' in field list is ambiguous"
    UPDATE SC_CTACTE_TEMP s,
        (SELECT codigo, name, COUNT(1) cantidad
        FROM sc_temp_cuotas
        GROUP BY codigo
        HAVING COUNT( codigo ) > 0
        ORDER BY codigo ASC) t1
    SET cod_stud = t1.codigo,
        fec_mov_cta = "2016-04-30",
        periodo = "201604",
        cant_ejemplares = t1.cantidad,
        name = t1.name
    WHERE s.cod_stud = t1.codigo
    
    PHP:
    What is wrong?
     
    Solved! View solution.
    piropeator, May 20, 2016 IP
  2. #2
    Probably that you have multiple name-columns in the different tables. Prefix the name column with the table name.
     
    PoPSiCLe, May 20, 2016 IP
  3. piropeator

    piropeator Well-Known Member

    Messages:
    194
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    121
    #3
    forget to punt "s." in every name-column.
    UPS!!
     
    piropeator, May 20, 2016 IP