优化sql

This commit is contained in:
wlx 2014-03-20 18:59:19 +00:00
parent 2e568a7cab
commit dd87964ad7
2 changed files with 4 additions and 4 deletions

View File

@ -88,10 +88,10 @@ class Qinghaihu implements SyncPluginInterface
{
if(!empty($this->last_sync))
{
$sql = "SELECT x.* FROM xml x";
$sql = "SELECT x.* FROM xml x where x.id in (select id from normalmetadata)";
}else{
$sql = "SELECT x.* FROM xml x
LEFT JOIN metadata m ON x.id=m.id
LEFT JOIN normalmetadata m ON x.id=m.id
WHERE m.ts_created > '{$this->last_sync}'";
}
$rs = $this->db->query($sql);

View File

@ -90,8 +90,8 @@ class Sanjiangyuan implements SyncPluginInterface
$sql = "SELECT * FROM xml where id in (select id from normalmetadata)";
}else{
$sql = "SELECT x.* FROM xml x
LEFT JOIN metadata m ON x.id=m.id
WHERE m.ts_created > '{$this->last_sync}' AND m.id in (select id from normalmetadata)";
LEFT JOIN normalmetadata m ON x.id=m.id
WHERE m.ts_created > '{$this->last_sync}'";
}
$sql = "SELECT * FROM xml where id in (select id from normalmetadata)";
$rs = $this->db->query($sql);