我在下面有一个很长的选择语句,当我运行它时,我在Node服务器上收到的错误数据太长了,但是当我将它粘贴到MySQL Workbench时它工作正常。我该如何解决此问题?
SELECT `199_roster`.`first`, `199_roster`.`last`, `199_roster`.`gender`, `199_roster`.`grade`, `199_results`.`ath_id`, `199_results`.`place`, `199_results`.`date`, `199_results`.`comment`, `199_results`.`100m Hurdles (F)`, `199_results`.`110m Hurdles (M)`, `199_results`.`100m Dash (F)`, `199_results`.`100m Dash (M)`, `199_results`.`1600m Run (F)`, `199_results`.`1600m Run (M)`, `199_results`.`4x100m Relay (F)`, `199_results`.`4x100m Relay (M)`, `199_results`.`400m Dash (F)`, `199_results`.`400m Dash (M)`, `199_results`.`200m Hurdles (F)`, `199_results`.`200m Hurdles (M)`, `199_results`.`800m Run (F)`, `199_results`.`800m Run (M)`, `199_results`.`200m Dash (F)`, `199_results`.`200m Dash (M)`, `199_results`.`4x400m Relay (F)`, `199_results`.`4x400m Relay (M)`, `199_results`.`High Jump (F)`, `199_results`.`High Jump (M)`, `199_results`.`Long Jump (F)`, `199_results`.`Long Jump (M)`, `199_results`.`Shot Put (F)`, `199_results`.`Shot Put (M)`, `199_results`.`Discus (F)`, `199_results`.`Discus (M)`, `199_results`.`Pole Vault (F)`, `199_results`.`Pole Vault (M)`, `199_results`.`3200m Run (M)`, `199_results`.`3200m Run (F)`, `199_results`.`300m Hurdles (M)`, `199_results`.`300m Hurdles (F)`, `199_results`.`4x800m Relay (M)`, `199_results`.`4x800m Relay (F)`, `199_results`.`100m Hurd. Trial (F)`, `199_results`.`110m Hurd. Trial (M)`, `199_results`.`100m Dash Trial (F)`, `199_results`.`100m Dash Trial (M)`, `199_results`.`200m Dash Trial (F)`, `199_results`.`200m Dash Trial (M)`, `199_results`.`400m Hurdles (F)`, `199_results`.`400m Hurdles (M)`, `199_results`.`2000m Steeplechase (F)`, `199_results`.`2000m Steeplechase (M)`, `199_results`.`3000m Steeplechase (F)`, `199_results`.`3000m Steeplechase (M)`, `199_results`.`1500m Run (F)`, `199_results`.`1500m Run (M)`, `199_results`.`3000m Run (F)`, `199_results`.`3000m Run (M)`, `199_results`.`5000m Run (F)`, `199_results`.`5000m Run (M)`, `199_results`.`10000m Run (F)`, `199_results`.`10000m Run (M)`, `199_results`.`Triple Jump (F)`, `199_results`.`Triple Jump (M)`, `199_results`.`Hammer Throw (F)`, `199_results`.`Hammer Throw (M)`, `199_results`.`Javelin Throw (F)`, `199_results`.`Javelin Throw (M)`, `199_results`.`Distance Medley Relay (F)`, `199_results`.`Distance Medley Relay (M)`, `199_results`.`Sprint Medley Relay (F)`, `199_results`.`Sprint Medley Relay (M)`, `199_results`.`4x200m Relay (F)`, `199_results`.`4x200m Relay (M)`, `199_results`.`4x1500m Relay (F)`, `199_results`.`4x1500m Relay (M)`, `199_results`.`4x1600m Relay (F)`, `199_results`.`4x1600m Relay (M)`, `199_results`.`Shuttle Hurdle Relay (F)`, `199_results`.`Shuttle Hurdle Relay (M)`, `199_results`.`60m Dash Trial (F)`, `199_results`.`60m Dash Trial (M)`, `199_results`.`60m Dash (F)`, `199_results`.`60m Dash (M)`, `199_results`.`60m Hurd. Trial (F)`, `199_results`.`60m Hurd. Trial (M)`, `199_results`.`60m Hurdles (F)`, `199_results`.`60m Hurdles (M)`, `199_results`.`50m Dash Trial (F)`, `199_results`.`50m Dash Trial (M)`, `199_results`.`50m Dash (F)`, `199_results`.`50m Dash (M)`, `199_results`.`50m Hurd. Trial (F)`, `199_results`.`50m Hurd. Trial (M)`, `199_results`.`50m Hurdles (F)`, `199_results`.`50m Hurdles (M)`, `199_results`.`55m Dash Trial (F)`, `199_results`.`55m Dash Trial (M)`, `199_results`.`55m Dash (F)`, `199_results`.`55m Dash (M)`, `199_results`.`55m Hurd. Trial (F)`, `199_results`.`55m Hurd. Trial (M)`, `199_results`.`55m Hurdles (F)`, `199_results`.`55m Hurdles (M)`, `199_results`.`100y Dash (F)`, `199_results`.`100y Dash (M)`, `199_results`.`Mile Run (F)`, `199_results`.`Mile Run (M)` FROM `199_results` INNER JOIN `199_roster` ON `199_roster`.`ath_id` = `199_results`.`ath_id` WHERE `199_results`.`date` BETWEEN '2018-04-01 00:00:01' AND '2018-05-08 23:59:59';
这是我进行查询的.js文件的一部分。 (通常我在客户端创建查询并动态发送,但是为了调试,我将变量设置如下)
var fullQuery = "SELECT * FROM `199_results` INNER JOIN `199_roster` ON `199_roster`.`ath_id` = `199_results`.`ath_id` WHERE `199_results`.`date` BETWEEN '2018-04-01 00:00:01' AND '2018-05-08 23:59:59';"
const db = require("../db");
db.query(fullQuery, (err, rows, fields) => {
if (err) {
res.render("results", {
title: "Results",
mysqlError: err.message
})
return console.error('stupid error', err)
} else {
req.session.results = rows;
res.send(rows)
}
})
如果有帮助,可以在错误消息中找到更多内容:
错误:ER_DATA_TOO_LONG:第1行的列'数据'的数据太长 在Query.Sequence._packetToError(/ root / site / node_modules / mysql / lib / protocol /sequences/Sequence.js:52:14) 在Query.ErrorPacket(/ root / site / node_modules / mysql / lib / protocol / sequences / Q uery.js:77:18) 在Protocol._parsePacket(/ root / site / node_modules / mysql / lib / protocol / Protoco l.js:279:23) 在Parser.write(/root/site/node_modules/mysql/lib/protocol/Parser.js:76:12) 在Protocol.write(/root/site/node_modules/mysql/lib/protocol/Protocol.js:39:16) 在Socket。 (/root/site/node_modules/mysql/lib/Connection.js:103:2 8) 在emitOne(events.js:116:13) 在Socket.emit(events.js:211:7) 在addChunk(_stream_readable.js:263:12) 在readableAddChunk(_stream_readable.js:250:11) -------------------- 在Pool.query(/root/site/node_modules/mysql/lib/Pool.js:199:23) 在MySQLStore.set(/root/site/node_modules/express-mysql-session/index.js:19 9:19) 在Session.save(/root/site/node_modules/express-session/session/session.js:72:25) 在Session.save(/root/site/node_modules/express-session/index.js:381:15) 在ServerResponse.end(/root/site/node_modules/express-session/index.js:330:21) 在ServerResponse.send(/root/site/node_modules/express/lib/response.js:221:10) 在ServerResponse.json(/root/site/node_modules/express/lib/response.js:267:15) 在ServerResponse.send(/root/site/node_modules/express/lib/response.js:158:21) 在Query.db.query [as _callback](/ root/site/routes/resultsRouter.js:184:9) 在Query.Sequence.end(/ root / site / node_modules / mysql / lib / protocol / sequences / Sequence.js:88:24)
答案 0 :(得分:0)
由于您要检索如此多的数据,所以不能只做
SELECT * FROM FROM `199_results` INNER JOIN `199_roster` ON
`199_roster`.`ath_id` = `199_results`.`ath_id` WHERE `199_results`.`date`
BETWEEN '2018-04-01 00:00:01' AND '2018-05-08 23:59:59';