早上好,我正在对数据进行查询,并且在查询中需要创建一个规则来仅获取所选的值。
我的MySQL
$query_rs = "(SELECT * FROM `financ_receita` WHERE data BETWEEN '2011-01-01' AND '2013-12-30') UNION ALL (SELECT * FROM `financ_despesa` WHERE data BETWEEN '2011-01-01' AND '2013-12-30')";
查看一切如何开始的图片:
当我点击GENERATE时,将表单发送到POST并按照以下步骤发送:
HIERARQUIA = 3,4
上述两个数字由字段hierarquia[]
发送,并按如下方式捕获:
$hierarquia = implode(",", $_POST['hierarquia']);
是否只能预约变量$hierarquia
捕获的值?
答案 0 :(得分:0)
你忘掉了小提琴中的AND
:
(
SELECT planoDeConta FROM `financ_receita`
WHERE data BETWEEN '2011-01-01' AND '2013-12-30'
and planoDeConta IN (3,4)
) UNION ALL (
SELECT planoDeConta FROM `financ_despesa`
WHERE data BETWEEN '2011-01-01' AND '2013-12-30'
and planoDeConta IN (3,4)
)
它将返回以下内容
PLANODECONTA
3
3
4
4
4
当然,如果您需要其他列,可以在select
子句中添加。