Select 在一个主键区间 SQL
Select in a primary key interval SQL
在学校我们看到你可以这样select:
SELECT *
FROM BLALBLA
WHERE id=1 AND id = 2 AND id=3 AND id=4
但是我们该怎么做:
SELECT
FROM BLABLA
WHERE id = 1 to 4
谢谢
戈德曼
Jarlh 找到了答案
"id between 1 and 4 – jarlh 53 secs ago"
谢谢
SELECT * FROM BLABLA WHERE id => 1 AND id =< 4
有几种方法
1) 如果 id
字段是整数。
SELECT *
FROM BLALBLA
WHERE id between 1 and 4
SELECT *
FROM BLALBLA
WHERE id => 1 AND id =< 4
SELECT *
FROM BLALBLA
WHERE id IN (1,2,3,4)
2) 如果 id
是 varchar
SELECT *
FROM BLALBLA
WHERE id IN ('1','2','3','4')
在学校我们看到你可以这样select:
SELECT *
FROM BLALBLA
WHERE id=1 AND id = 2 AND id=3 AND id=4
但是我们该怎么做:
SELECT
FROM BLABLA
WHERE id = 1 to 4
谢谢 戈德曼
Jarlh 找到了答案 "id between 1 and 4 – jarlh 53 secs ago" 谢谢
SELECT * FROM BLABLA WHERE id => 1 AND id =< 4
有几种方法
1) 如果 id
字段是整数。
SELECT *
FROM BLALBLA
WHERE id between 1 and 4
SELECT *
FROM BLALBLA
WHERE id => 1 AND id =< 4
SELECT *
FROM BLALBLA
WHERE id IN (1,2,3,4)
2) 如果 id
是 varchar
SELECT *
FROM BLALBLA
WHERE id IN ('1','2','3','4')