对于mysql表格,我有10行数据,其中5行的
我想要根据日期从每个
这是目前我的进展:
post_id
为5
,另外5行的post_id
为234
。我想要根据日期从每个
post_id
中选择2行数据:这是目前我的进展:
$post_ids = $_POST['id'][0];
$ids = implode(',', $post_ids); //id's in ',' format
$query = "SELECT * FROM $table WHERE post_id in ({$ids}) ORDER by date desc limit 2";
这只返回匹配两个 ID 之一的前两个结果。我需要为每个查询运行 foreach
函数吗?是否有其他方法?
谢谢!