尝试解决此错误的总NOOB。我最近切换了服务器,突然之前用于完美工作的表/ sql查询现在显示以下错误:
非法混合归类(utf8_general_ci,IMPLICIT)和(latin1_swedish_ci,NUMERIC)for gt;操作'<>' SQL = SELECT ...
我在表中有一个结构,包括TIME字段和INT字段。当我将时间字段数据类型切换为INT而不是TIME时,错误消失。不幸的是,时间数据也是如此(显示0:00)。
SQL查询如下所示:
SELECT
OverallRank,
First,
Last,
Affiliate,
Part1Number,
Part1NumberRank,
Part2Number,
Part2NumberRank,
DATE_FORMAT(Part1Time, '%i:%s') as Part1Time,
Part1TimeRank,
Part3Number,
Part3NumberRank,
AgeGroup
FROM
(SELECT
First,
Last,
Affiliate,
AgeGroup,
Part1Number,
Part2Number,
Part1Time,
Part3Number,
Part1NumberRank,
Part2NumberRank,
Part1TimeRank,
Part3NumberRank,
(Part1NumberRank + Part2NumberRank + Part1TimeRank + Part3NumberRank) AS Total,
@overallrank:=CASE WHEN @total <> (Part1NumberRank + Part2NumberRank + Part1TimeRank + Part3NumberRank) THEN @overallrank+1 ELSE @overallrank+0 END AS OverallRank,
@total:=(Part1NumberRank + Part2NumberRank + Part1TimeRank + Part3NumberRank) AS TTL
FROM
(SELECT @overallrank:=0) overallrank,
(SELECT @total:=0) ttl,
(SELECT
First,
Last,
Affiliate,
AgeGroup,
Part1Number,
Part2Number,
Part1Time,
Part3Number,
Part1NumberRank,
Part2NumberRank,
Part1TimeRank,
@rank4:=CASE WHEN @Part3Number <> Part3Number THEN @rank4+1 ELSE @rank4+0 END AS Part3NumberRank,
@Part3Number:=Part3Number AS P4
FROM
(SELECT @rank4:=0) r4,
(SELECT @Part3Number:=0) p4,
(SELECT
First,
Last,
Affiliate,
AgeGroup,
Part1Number,
Part2Number,
Part1Time,
Part3Number,
Part1NumberRank,
Part2NumberRank,
@rank3:=CASE WHEN @Part1Time <> Part1Time THEN @rank3+1 ELSE @rank3+0 END AS Part1TimeRank,
@Part1Time:=Part1Time AS P3
FROM
(SELECT @rank3:=0) r3,
(SELECT @Part1Time:=0) p3,
(SELECT
First,
Last,
Affiliate,
AgeGroup,
Part1Number,
Part2Number,
Part1Time,
Part3Number,
Part1NumberRank,
@rank2:=CASE WHEN @Part2Number <> Part2Number THEN @rank2+1 ELSE @rank2+0 END AS Part2NumberRank,
@Part2Number:=Part2Number AS P2
FROM
(SELECT @rank2:=0) r2,
(SELECT @Part2Number:=0) p2,
(SELECT
First,
Last,
Affiliate,
AgeGroup,
Part1Number,
Part2Number,
Part1Time,
Part3Number,
@rank1:=CASE WHEN @Part1Number <> Part1Number THEN @rank1+1 ELSE @rank1+0 END AS Part1NumberRank,
@Part1Number:=Part1Number AS P1
FROM
(SELECT @rank1:=0) r1,
(SELECT @Part1Number:=0) p1,
(SELECT
*
FROM
#__results
WHERE
EventName = '2011EoSummer' AND
Gender = {$REQUEST:Gender} AND
({$REQUEST:Age} = 'Overall' OR AgeGroup = {$REQUEST:Age})
ORDER BY
Part1Number DESC
) T1
) T2
ORDER BY
Part2Number DESC
) T3
ORDER BY
Part1Time ASC
) T4
ORDER BY
Part3Number DESC
) T5
ORDER BY
Total ASC
) T6
任何帮助都会非常感激
我尝试在PHPMyADMIN中运行查询并获得以下内容:
答案 0 :(得分:1)
这是一个由我的托管公司解决的问题......这是他们在联系后的回复。
您当前使用的数据库似乎默认使用服务器的默认信息。这可能发生在帐户移动期间,或通过php配置。我们准备了一个脚本,您可以运行该脚本以快速更改任何数据库的排序规则。有关更多信息,请参阅以下内容:
http://www.inmotionhosting.com/support/website/databases/how-to-convert-a-database-to-utf-8
更新排序规则后,您应该能够毫无错误地运行查询。
答案 1 :(得分:0)
显然,查询中的列/表具有不同的排序规则,对于某些操作来说是非法的。
尝试将所涉及的表/列更改为单个排序规则。