hi all
i spent 2 days to find out my mistake.... but failed
i m completely stuck out from my code plz help me out
:'(
I am trying to update one field(ecode) of my at0310 table from emp_company table's ecode within same database(master)...
i tried update query with diff styles but noting happend.......
my at0310 table having ecardno,attime,atdate,IO and ecode..
ecode field is empty inside at0310 table........ and i want dat value from emp_company table dat matches with ecardno of both tables.
here is code-:
<head>
<title></title>
</head>
<body>
<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("master", $con);
$query= "UPDATE at0310 SET ecode = ( SELECT ecode
FROM emp_company WHERE at0310.ecardno = emp_company.ecardno)
WHERE EXISTS ( SELECT ecode
FROM emp_company WHERE at0310.ecardno = emp_company.ecardno)";
//$query="SELECT emp_company.ecode
//FROM emp_company
//LEFT JOIN at0310
//ON emp_company.ecardno = at0310.ecardno";
if (mysql_query($query, $con))
{
echo "record updated !";
}
else
{
echo "something went wrong";
}
mysql_close($con)
?>
</BODY>
</HTML>