MySQL:在行列表中,使用给定的值查找正确的行
我有一张叫打折的桌子MySQL:在行列表中,使用给定的值查找正确的行,mysql,Mysql,我有一张叫打折的桌子 Field Type id int(11) NOT NULL resort_id int(11) NOT NULL count_from int(11) NULL count_to int(11) NULL discount varchar(255) NULL 我有如下几行: 当我得到27作为输入时,我应该检索第一行id:1。假设我的输入是33,我应该检索2个rowid:2 如何编写mysql查询 问候,, 普
Field Type
id int(11) NOT NULL
resort_id int(11) NOT NULL
count_from int(11) NULL
count_to int(11) NULL
discount varchar(255) NULL
我有如下几行:
当我得到27作为输入时,我应该检索第一行id:1。假设我的输入是33,我应该检索2个rowid:2
如何编写mysql查询
问候,,
普拉布
id |product_id |count_from |count_to |discount
1|8 |0 |30 |22
2|8 |31 |60 |12
SELECT *
FROM discounts
WHERE 27 BETWEEN count_from AND count_to
SELECT *
FROM discounts
WHERE 33 BETWEEN count_from AND count_to