我试图在两个表上以特定的顺序和范围创建一个自然连接。
我的table
dictionary
+-------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+----------------+
| wid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| word | varchar(56) | NO | UNI | NULL | |
+-------+------------------+------+-----+---------+----------------+
g219
+-------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+----------------+
| pos | int(10) unsigned | NO | PRI | NULL | auto_increment |
| wid | int(10) unsigned | NO | MUL | NULL | |
+-------+------------------+------+-----+---------+----------------+
dictionary有一组由唯一(区分大小写)单词和标记组成的字典,每个单词和标记都有一个id号。g219本质上是一本书,pos是单词/标签在书中的位置,wid是字典中相应的单词id。我可以执行一个完整的自然连接来按如下方式布置书本:
SELECT word FROM dictionary
NATURAL JOIN g219
ORDER BY g219.pos;
我也可以通过添加 LIMIT [n]
,但这只返回第一个 [N]
结果。我不知道如何将此限制在指定范围内。二者都
SELECT word FROM dictionary
NATURAL JOIN g219
ORDER BY g219.pos
WHERE pos BETWEEN 50 AND 100;
和
SELECT word FROM dictionary
NATURAL JOIN g219
ORDER BY g219.pos
WHERE pos > 50 AND pos < 100;
失败。
1条答案
按热度按时间mqkwyuun1#
先是“where”,然后是“order by”;)