gpt4 book ai didi

MySQL 报告 : Documentation #1064 - There is something wrong in the syntax used with "" on rule 3

转载 作者:行者123 更新时间:2023-11-29 15:26:22 24 4
gpt4 key购买 nike

我目前正在为学校做一项作业,我必须编写一个查询,但遇到错误。

分配如下:如果客户 A 访问分行 1,客户 B 访问分行 1 和 2,客户 C 访问分行 2,那么可以说客户 A 和 B 0 分行相互分离,客户 A 和 C 1 分行相互分离。找出两个随机客户相距多少个分行。

我收到此错误

SQL-query: Documentatie
SELECT DISTINCT a.klant_idklant AS "KLANT A", b.klant_idklant AS "KLANT B", a.filiaal_idfiliaal AS "FILIAAL A", b.filiaal_idfiliaal AS "FILIAAL B", ABS(a.filiaal_idfiliaal - b.filiaal_idfiliaal) AS "FILIALEN VAN ELKAAR VERWIJDERD"
FROM aankoop a, aankoop b
WHERE a.klant_idklant = FLOOR(RAND()(SELECT MAX(idklant) FROM klant) - (SELECT MIN(idklant) FROM klant) + (SELECT MIN(idklant) FROM klant))
AND b.klant_idklant = FLOOR(RAND()(SELECT MAX(idklant) FROM klant) - (SELECT MIN(idklant) FROM klant) + (SELECT MIN(idklant) FROM klant)) LIMIT 0, 25

MySQL reports: Documentation
#1064 - There is something wrong in the syntax used with '(SELECT MAX(idklant) FROM klant) - (SELECT MIN(idklant) FROM klant) + (SELECT MI' on rule 3

这是我当前的查询

SELECT DISTINCT a.klant_idklant AS "KLANT A"
, b.klant_idklant AS "KLANT B"
, a.filiaal_idfiliaal AS "FILIAAL A"
, b.filiaal_idfiliaal AS "FILIAAL B"
, ABS(a.filiaal_idfiliaal - b.filiaal_idfiliaal) AS "FILIALEN VAN ELKAAR VERWIJDERD"
FROM aankoop a
, aankoop b
WHERE a.klant_idklant = FLOOR(RAND()(SELECT MAX(idklant) FROM klant) -
(SELECT MIN(idklant) FROM klant) +
(SELECT MIN(idklant) FROM klant)
)
AND b.klant_idklant = FLOOR(RAND()(SELECT MAX(idklant) FROM klant) -
(SELECT MIN(idklant) FROM klant) +
(SELECT MIN(idklant) FROM klant)
)

这是 Database Structure

最佳答案

问题是您没有将子查询的结果与 RAND() 相乘。你应该有:

SELECT DISTINCT a.klant_idklant AS "KLANT A"
, b.klant_idklant AS "KLANT B"
, a.filiaal_idfiliaal AS "FILIAAL A"
, b.filiaal_idfiliaal AS "FILIAAL B"
, ABS(a.filiaal_idfiliaal - b.filiaal_idfiliaal) AS "FILIALEN VAN ELKAAR VERWIJDERD"
FROM aankoop a
, aankoop b
WHERE a.klant_idklant = FLOOR(RAND()*(SELECT MAX(idklant) FROM klant) -
(SELECT MIN(idklant) FROM klant) +
(SELECT MIN(idklant) FROM klant)
)
AND b.klant_idklant = FLOOR(RAND()*(SELECT MAX(idklant) FROM klant) -
(SELECT MIN(idklant) FROM klant) +
(SELECT MIN(idklant) FROM klant)

关于MySQL 报告 : Documentation #1064 - There is something wrong in the syntax used with "" on rule 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59056015/

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