query excuting problem
i tried to execute following query in php script.
$db_selected = mysql_select_db("lumiinc1_sndemo1", $con);
if ($db_selected) {
echo "database connected";
}
else
{
die ("Can\'t use db : " . mysql_error());
}
$sql = "INSERT INTO `markers` ( `name`, `address`, `lat`, `lng`, `id` ) SELECT `name`, `street`, `latitude`, `longitude`, `lid` FROM `location` WHERE NOT EXISTS ( SELECT * FROM `markers` WHERE `location`.`lid` = `markers`.`id` )";
$result = mysql_query($sql);
if ($result) {
echo "Query executed OK";
} else {
die("Invalid query: " . mysql_error());
}
script does not show any error.also query executed.but i didn't get my expected result.at the same i try this query in phpmyAdmin i got my expected result. i dont know the cause of this problem. plz any 开发者_开发百科one find the problem . thanks
script does not show any error
Have you got error reporting enabled? Have you tested it with trigger_error() ?
but i didn't get my expected result
What did you get?
What did you expect?
- and BTW, it'd be a lot more efficient to drop the sub-query from the select and use INSERT IGNORE (assuming id has a unique index).
C.
精彩评论