看板 Database 關於我們 聯絡資訊
前面五張表格,所以用 subquery 就算了 這只有一張表格用什麼 subquery... SELECT * FROM boards WHERE board_name IN (1,2,3,4,5) ORDER BY posttime LIMIT 5 資料庫系統不支援 IN 的話,可以換成 WHERE board_name = 1 OR board_name = 2 OR ... ※ 引述《gargamel (Nerding)》之銘言: : 抄的...XD : select * from ( : (select * from boards : where board_name = '1' : order by posttime limit 5) union : (select * from boards : where board_name = '2' : order by posttime limit 5) union : (select * from boards : where board_name = '3' : order by posttime limit 5) union : (select * from boards : where board_name = '4' : order by posttime limit 5) union : (select * from boards : where board_name = '5' : order by posttime limit 5)) : order by posttime limit 5; : 這樣? : ※ 引述《pakker (找尋蔚藍天空)》之銘言: : : select * from ( : : (select * from board1 order by posttime limit 5) union : : (select * from board2 order by posttime limit 5) union : : (select * from board3 order by posttime limit 5) union : : (select * from board4 order by posttime limit 5) union : : (select * from board5 order by posttime limit 5) union : : ) AS U order by posttime limit 5; : : 這樣? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 134.208.33.185