gpt4 book ai didi

MySQL WHERE IN 问题

转载 作者:行者123 更新时间:2023-11-29 09:15:12 25 4
gpt4 key购买 nike

卫生部!现在已经解决了:

人为错误:如果我按照下面每个人的建议迭代数据,则会有所帮助...添加以下代码来循环结果...

while ($rowprevprev = mysql_fetch_assoc($resultprevprev)) {
print_r($rowprevprev);
}

[羞愧地低下头......适本地尴尬......]

大家干杯!

H.

嗨,

有一段简单的代码(感谢之前的帖子):

SELECT
AVG (q1) AS q1, AVG (q2) AS q2, AVG (q3) AS q3, AVG (q4) AS q4,
AVG (q5) AS q5, AVG (q6) AS q6, AVG (q7) AS q7, AVG (q8) AS q8,
AVG (q9) AS q9, AVG (q10) AS q10, AVG (q11) AS q11, AVG (q12) AS q12,
AVG (q13) AS q13, AVG (q14) AS q14, AVG (q15) AS q15, AVG (q16) AS q16,
AVG (q17) AS q17, AVG (q18) AS q18, AVG (q19) AS q19, AVG (q20) AS q20,
AVG (q21) AS q21, AVG (q22) AS q22
FROM thotels_results
WHERE brand IN ('XYZ','ABC','EFG')
AND date = 'NOV2010' GROUP BY brand;

使用查询浏览器的输出是:

q1       q2       q3       q4       q5       q6       q7       q8       q9       q10      q11      q12      q13      q14      q15      q16      q17      q18      q19      q20      q21      q22
8.1724 8.2414 8.2414 7.8966 8.5862 8.5517 9.0000 8.5862 8.1724 7.9655 8.8966 8.6207 8.2414 8.3793 7.8276 8.3793 7.9310 8.4138 8.6897 8.3448 8.8621 8.5172
8.7714 8.8429 8.1643 8.7500 8.7571 8.9000 9.4071 9.1214 8.5714 8.7643 9.5143 8.9429 9.1643 8.9857 7.9500 8.9286 8.7000 9.0429 9.0143 8.7214 9.1214 9.3071
8.6009 8.5686 7.8528 8.3133 8.3423 8.6410 9.0301 8.6912 8.3233 8.3389 9.2029 8.3969 8.6856 8.5017 7.8071 8.4816 8.3512 8.6789 8.6789 8.3913 8.6388 8.8986

但是,当我VAR_DUMP时,我得到以下信息,似乎并非所有数据都在那里:

array
0 => string '8.1724' (length=6)
'q1' => string '8.1724' (length=6)
1 => string '8.2414' (length=6)
'q2' => string '8.2414' (length=6)
2 => string '8.2414' (length=6)
'q3' => string '8.2414' (length=6)
3 => string '7.8966' (length=6)
'q4' => string '7.8966' (length=6)
4 => string '8.5862' (length=6)
'q5' => string '8.5862' (length=6)
5 => string '8.5517' (length=6)
'q6' => string '8.5517' (length=6)
6 => string '9.0000' (length=6)
'q7' => string '9.0000' (length=6)
7 => string '8.5862' (length=6)
'q8' => string '8.5862' (length=6)
8 => string '8.1724' (length=6)
'q9' => string '8.1724' (length=6)
9 => string '7.9655' (length=6)
'q10' => string '7.9655' (length=6)
10 => string '8.8966' (length=6)
'q11' => string '8.8966' (length=6)
11 => string '8.6207' (length=6)
'q12' => string '8.6207' (length=6)
12 => string '8.2414' (length=6)
'q13' => string '8.2414' (length=6)
13 => string '8.3793' (length=6)
'q14' => string '8.3793' (length=6)
14 => string '7.8276' (length=6)
'q15' => string '7.8276' (length=6)
15 => string '8.3793' (length=6)
'q16' => string '8.3793' (length=6)
16 => string '7.9310' (length=6)
'q17' => string '7.9310' (length=6)
17 => string '8.4138' (length=6)
'q18' => string '8.4138' (length=6)
18 => string '8.6897' (length=6)
'q19' => string '8.6897' (length=6)
19 => string '8.3448' (length=6)
'q20' => string '8.3448' (length=6)
20 => string '8.8621' (length=6)
'q21' => string '8.8621' (length=6)
21 => string '8.5172' (length=6)
'q22' => string '8.5172' (length=6)

VAR_DUMP 似乎只返回查询的第一行,而不是全部三行。我需要访问所有三行数据,以便执行计算。

有人有任何想法和/或建议吗?

谢谢

荷马。

最佳答案

问题不在于 var_dump,而在于您用来从 MySQL 获取数据的代码。请参阅this question从昨天开始 - 我认为你犯了同样的错误。

关于MySQL WHERE IN 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4374688/

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