How to get an auto increment id and join it to a variable in the same insert

1

How to get a newly created auto increment ID and repeat it in another column by joining it to a variable?

 Ex: Na hora do Insert pego idxxxx  repito somando a $varxxxx


  date_default_timezone_set('UTC');
  while (strtotime($start) <= strtotime($data_fim)) { // pega a data de inicio e a   
  data fim e faz o loop inserindo no mysql

  $sql = mysql_query ("INSERT INTO agenda_saidas(nome,url)
  VALUES('nome','agendados_ver.php?id=$varxxxxxx')",
  $conexao) or die( mysql_error());
    
asked by anonymous 14.05.2015 / 21:41

1 answer

2

As far as I know, this is not possible. You must first do INSERT , and then UPDATE :

UPDATE agenda_saidas
SET url = CONCAT(url, id)
WHERE id = LAST_INSERT_ID()
    
14.05.2015 / 21:50