gpt4 book ai didi

php - MYSQL - 获取适当的现金返还值

转载 作者:行者123 更新时间:2023-11-30 00:23:28 24 4
gpt4 key购买 nike

我有 1 个 mysql 表,其中包含以下值。

When pass value as 5, it should return cashback_vaule = 1
because passed value within 1-10 range & its cashback_vaule is 1

When pass value as 25, it should return cashback_vaule = 3
because passed value within 21-30 range & its cashback_vaule is = 3

When pass value more than 30, it should return cashback_vaule = 3
because max cashback_vaule is = 3

我需要进行查询以相应地获取cashback_vaule。

tbl_cashback

-------------------------------------------------------------
id cashback_range_from cashback_range_to cashback_vaule(%)
-------------------------------------------------------------
1 1 10 1
2 11 20 2
3 21 30 3
-------------------------------------------------------------

最佳答案

你可以试试这个

$your_value = "5";

$sql = "SELECT * FROM tbl_cashback
WHERE '$your_value'>=cashback_range_from
AND '$your_value'<=cashback_range_to ";

关于php - MYSQL - 获取适当的现金返还值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23053163/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com