-schema
CREATE TABLE `ratings` (
`id` int(11) NOT NULL default '0',
`rating` int(11) NOT NULL default '1',
`rating_start` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) TYPE=MyISAM
-myprogram.php
foreach($ids as $id){
$sql = "SELECT rating FROM ratings WHERE id = '$id' AND rating_start >= NOW()";
$sql .= "ORDER BY rating_start DESC LIMIT 1;"
$ret = $db->execute($id);
}
我可以从查询中查找相同的日期吗?
现在我在foreach中有很多疑问
答案 0 :(得分:0)
呀。我会做substr(implode(",",$ids),0,-1)
。否则你会在你的ID结尾留下一个逗号。