Thursday 15 July 2010

mysql - SQL statement errors in PHP but ok in SQL -



mysql - SQL statement errors in PHP but ok in SQL -

the next sql statement runs correctly against mysql database table in sql script or in phpmyadmin errors when run within php script.

the sql statement is:

update traceability t1 inner bring together traceability t2 on (t1.parent in (select t2.child)) set t1.root=false;

in php script code looks like:

$sqlupdatestmt = $db->query("update traceability t1 inner bring together traceability t2 on (t1.parent in (select t2.child)) set t1.root=false;"); $sqlupdatestmt->execute();

the error in php log is:

php fatal error: uncaught exception 'pdoexception' message 'sqlstate[42s22]: column not found: 1054 unknown column 't2.child' in 'field list'' in /<myfilepath> /traceability.php:50 stack trace: #0 /<myfilepath>/traceability.php(50): pdo->query('update traceabi...') #1 {main}

what's going wrong in php throws php/sql error?

here info on traceability table schema:

field type null key default variant varchar(20) yes mul null parent varchar(50) yes null kid varchar(50) yes null relation varchar(20) yes null root tinyint(1) yes null leaf tinyint(1) yes null

try

class="snippet-code-html lang-html prettyprint-override">update traceability t1 set t1.root=false t1.parent in (select kid traceability)

anas

php mysql sql

No comments:

Post a Comment