gpt4 book ai didi

php - 连接两个表并查看极值 - 查询无法正常工作

转载 作者:行者123 更新时间:2023-11-30 01:00:18 25 4
gpt4 key购买 nike

我有两个表,我连接两个表并希望显示选择一列的极值,这是 php/mysql 代码。

$sql="Select A.date, A.rainfall, A.evep , 
A.max_temp , A.min_temp , A.sunshine_hrs ,
B.temp_air , B.dry_temp ,B.wet_temp,
B.rel_humid , B.soil_temp_5, B.soil_temp_20,
B.soil_temp_30 , B.soil_temp_60 ,
B.air_pressure
FROM reg_data3 A
INNER JOIN reg_data2 B
ON A.date = B.date
WHERE year(DATE_FORMAT(A.date, '%y-%m-%d'))='".$year."'
and month(DATE_FORMAT(A.date, '%y-%m-%d'))='".$month."'
ORDER BY B.date and $paramiter > $value ";

当回显查询时;首先我选择 $year=2008 $month=2 和 $parameter=soil_temp_60 和 $value=20

Select A.date, A.rainfall, A.evep , A.max_temp , 
A.min_temp , A.sunshine_hrs , B.temp_air ,
B.dry_temp ,B.wet_temp, B.rel_humid ,
B.soil_temp_5 ,B.soil_temp_20 , B.soil_temp_30 ,
B.soil_temp_60 , B.air_pressure
FROM reg_data3 A
INNER JOIN reg_data2 B
ON A.date = B.date
WHERE year(DATE_FORMAT(A.date, '%y-%m-%d'))='2008'
and month(DATE_FORMAT(A.date, '%y-%m-%d'))='02'
ORDER BY B.date and A.soil_temp_60 > 24 ;

表中存在与此查询相关的极端值,但效果不佳

最佳答案

我认为您的问题是变量放在错误的位置,请尝试以下操作:

$sql="Select A.date, A.rainfall, A.evep , 
A.max_temp , A.min_temp , A.sunshine_hrs ,
B.temp_air , B.dry_temp ,B.wet_temp,
B.rel_humid , B.soil_temp_5, B.soil_temp_20,
B.soil_temp_30 , B.soil_temp_60 ,
B.air_pressure
FROM reg_data3 A
INNER JOIN reg_data2 B
ON A.date = B.date
WHERE year(DATE_FORMAT(A.date, '%y-%m-%d'))='".$year."'
and month(DATE_FORMAT(A.date, '%y-%m-%d'))='".$month."'
and $paramiter > $value
ORDER BY B.date ";

关于php - 连接两个表并查看极值 - 查询无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20195580/

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