如何在sqlite中获得10个连接表的第一条记录?

时间:2012-08-12 12:01:41

标签: sqlite

如何在Sqlite中获得Nemayeh.Nemayeh字段的10条首次记录?

SELECT
  Keyword,
  Nemayeh.Nemayeh

FROM
  (SELECT
     Keyword.Id,
     Keyword.Keyword
   FROM Keyword
   ORDER BY Keyword.Keyword ASC
   LIMIT 10 OFFSET 0
  ) AS tmp

INNER JOIN KeyWord_Nemayeh
        ON KeyWord_Nemayeh.Id_Keyword = tmp.Id

INNER JOIN Nemayeh
        ON Nemayeh.Id = KeyWord_Nemayeh.Id_Nemayeh

ORDER BY 1,2

例如:

Key1 Nem1_1
Key1 Nem1_2
Key1 Nem1_3
.
.
.
Key1 Nem1_10
Key2 Nem2_1
Key2 Nem2_2
.
.
.
Key2 Nem2_10

2 个答案:

答案 0 :(得分:2)

这正是biziclop所说的,但应该有效。

SELECT
  Keyword,
  Nemayeh.Nemayeh
FROM
  (SELECT Keyword.Id,Keyword.Keyword 
   FROM Keyword
   ORDER BY Keyword.Keyword ASC
   LIMIT 10 OFFSET 0) AS tmp

INNER JOIN KeyWord_Nemayeh ON KeyWord_Nemayeh.Id_Keyword = tmp.Id

INNER JOIN Nemayeh ON Nemayeh.Id = KeyWord_Nemayeh.Id_Nemayeh

ORDER BY 1,2 LIMIT 0, 10 

答案 1 :(得分:1)

尝试:

SELECT TOP 10 Keyword,... FROM...