i am trying to get data from one table, I received data from one table but there is some problem in my first table i have 6 query and i allow max 12 query in result. In my query i received repeat query in my SQL please have a look. sorry for bad English.
$query = $this->db->query("SELECT * FROM yt_sub,done WHERE yt_sub.current < yt_sub.total AND done.link != yt_sub.url AND done.uid != '$id' ORDER BY RAND() LIMIT 12");
Using this SQL query i received 12 rows but according to this sql only 6 rows pass throw it, but i received 6 rows.
使用DISTINCT参见下面的示例
$query = $this->db->query("SELECT DISTINCT * FROM yt_sub,done WHERE yt_sub.current < yt_sub.total AND done.link != yt_sub.url AND done.uid != '$id' ORDER BY RAND() LIMIT 12");
使用GROUP BY
$query = $this->db->query("SELECT * FROM yt_sub,done WHERE yt_sub.current < yt_sub.total AND done.link != yt_sub.url AND done.uid != '$id' GROUP BY done.uid ORDER BY RAND() LIMIT 12");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.