SQL - UPDATE DESDE OTRA TABLA

 
Vista:

UPDATE DESDE OTRA TABLA

Publicado por erikur raudi (3 intervenciones) el 06/09/2007 16:10:58
HOLA, ESPERO ME PUEDAN AYUDAR CON ESTA DUDA.

EN MI BASE DE DATOS TENGO DOS TABLAS CON DIFERENTE NOMBRE PERO CON LA MISMA ESTRUCTURA.

LO QUE PRETENDO HACER ES:

ACTUALIZAR ALGUNOS CAMPOS DE LA TABLA1 APARTIR DE LA TABLA2.

COMO PUEDO HACER ESTO?

LLEVO VARIOS INTENTOS Y NINGUNO HA FUNCIONADO.

GRACIAS, ESPERO SUGERENCIAS.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:UPDATE DESDE OTRA TABLA

Publicado por Isaias (5072 intervenciones) el 06/09/2007 17:43:25
UPDATE t1 SET c1 = t2.c1
FROM tablaA t1 JOIN tablaB t2
ON t1.id = t2.id
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:UPDATE DESDE OTRA TABLA

Publicado por erikur raudi (3 intervenciones) el 07/09/2007 18:36:04
Hola de nuevo, te comento que ya hice mi consulta, es esta:

UPDATE desperdicio SET claved = copiadesp.claved FROM desperdicio JOIN copiadesp ON desperdicio.pedimentoi = copiadesp.pedimentoi

Pero envia un error porque necesita las comillas simples, entonces se las agrego:

UPDATE desperdicio SET claved = 'copiadesp.claved FROM desperdicio JOIN copiadesp ON desperdicio.pedimentoi = copiadesp.pedimentoi'

pero lo que hace es que pega esto:

'copiadesp.claved FROM desperdicio JOIN copiadesp ON desperdicio.pedimentoi = copiadesp.pedimentoi'

Y no es lo que quiero, en donde esta el error?

Te agradeceria mucho me respondieras esta duda, gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:UPDATE DESDE OTRA TABLA

Publicado por mary (1 intervención) el 19/02/2010 16:22:54
hola porfa necesito q me ayuden , necesito actualizar los campos de una tabla para a partir de otra, pero el campo con el que quiero actuallizar no aparece en ambas tablas. este es mi codigo.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>

<body>
<?php
session_start();
if(!isset($_SESSION['nivel']))
{
//header("Location: login.php");
//return 0;

}
$dsn="x";
$usuario="x";
$clave="x";

$conect=odbc_connect($dsn,$usuario,$clave);

$existe = 0;
if (!$conect){
exit("<strong>)Error al conectarse con la base de datos</strong>");
}

if (isset($_POST['Registrar'])) {
$sector = $_POST["sector"];
$MemoDespacho_not = $_POST["numero_memo"];
$FechaIngreso= $_POST["fecha_exportacion"];
$FechaRecepcion_Notif= $_POST["fecha_recep"];

$sector = $_POST['psector'];
$numero = $_POST['numero_memo'];
$exportacion = $_POST['fecha_exportacion'];


$sql="Update Liqui inner join PLiqui on (Liqui.Rif=PLiqui.Rif) and (Liqui.Secuencial=PLiqui.Secuencial) and (Liqui.FechaLiquidacion=PLiquidacion.FechaLiquidacion) SET (PLiqui.FechaRecep_Noti=date(),PLiqui.fecha_proceso=date(), PLiqui.xx=3) where ((PLiqui.Situacion_Liquidacion=4) and (PLiqui.sect=$sect and (Liqui.MemoDes_not=$numero) and (PLiqui.FechaIngreso='$exportacion'))";
$result=odbc_exec($conect,$sql);

$sql="Update Liqui SET PLiqui.MontoCifras=PLiqui.Montodiv,PLiqui.Multa=PLiqui.Montodiv where ((PLiqui.FechaRecep_Not=date()) and (PLiqui.Situacion_Liquidacion=4 and (PLiqui.Concurrente=1) and (PLiqui.sector=sector))";
$result=odbc_exec($conect,$sql);
}

?>
quiero actualizar los campos fecharecepcion_notif, fechaproceso,txrx pèro no se como hacerlo porfaayudenme , gracias!!
</body>
</html>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:UPDATE DESDE OTRA TABLA

Publicado por erikur raudi (2 intervenciones) el 19/02/2010 22:11:21
Puedes explicarme mas a detalle?.

Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar