gpt4 book ai didi

MySQL 说 : Documentation #1064 - You have an error in your SQL syntax; on Stored Procedure

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

我正在尝试创建以下过程:

CREATE  PROCEDURE `client_clinical_visit`()
DETERMINISTIC
COMMENT 'Client clinical visit '
BEGIN
SELECT
`db565263480`.`kp_bio_data`.`uuid` AS `uuid`,
`db565263480`.`kp_bio_data`.`firstname` AS `firstname`,
`db565263480`.`kp_bio_data`.`lastname` AS `lastname`,
`db565263480`.`kp_bio_data`.`id` AS `kp_bio_data_id`,
`db565263480`.`kp_bio_data`.`tel` AS `tel`,
`db565263480`.`kp_bio_data`.`gender` AS `gender`,
`db565263480`.`kp_bio_data`.`marital_status` AS `marital_status`,
`db565263480`.`kp_bio_data`.`education_level` AS `education_level`,
`db565263480`.`kp_bio_data`.`place_of_birth` AS `place_of_birth`,
`db565263480`.`kp_types`.`id` AS `kp_types_id`,
`db565263480`.`kp_types`.`Name` AS `name`,
`db565263480`.`kp_types`.`Abbrv` AS `abbrv`,
`db565263480`.`clinic_visit`.`disc_no` AS `disc_no`
FROM
((`kp_bio_data`
INNER JOIN `kp_types` ON ((`db565263480`.`kp_bio_data`.`kp_id` = `db565263480`.`kp_types`.`id`)))
INNER JOIN `clinic_visit` ON ((`db565263480`.`clinic_visit`.`uuid` = `db565263480`.`kp_bio_data`.`uuid`)));
END

但我不断收到以下错误:

MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 22

请告知如何解决这个问题...

最佳答案

您可能错过了分隔符,并且在选择查询中不需要大括号,因此只需删除它们即可,

delimiter //

CREATE PROCEDURE `client_clinical_visit`()
DETERMINISTIC
COMMENT 'Client clinical visit '
BEGIN
SELECT
`db565263480`.`kp_bio_data`.`uuid` AS `uuid`,
`db565263480`.`kp_bio_data`.`firstname` AS `firstname`,
`db565263480`.`kp_bio_data`.`lastname` AS `lastname`,
`db565263480`.`kp_bio_data`.`id` AS `kp_bio_data_id`,
`db565263480`.`kp_bio_data`.`tel` AS `tel`,
`db565263480`.`kp_bio_data`.`gender` AS `gender`,
`db565263480`.`kp_bio_data`.`marital_status` AS `marital_status`,
`db565263480`.`kp_bio_data`.`education_level` AS `education_level`,
`db565263480`.`kp_bio_data`.`place_of_birth` AS `place_of_birth`,
`db565263480`.`kp_types`.`id` AS `kp_types_id`,
`db565263480`.`kp_types`.`Name` AS `name`,
`db565263480`.`kp_types`.`Abbrv` AS `abbrv`,
`db565263480`.`clinic_visit`.`disc_no` AS `disc_no`
FROM
`kp_bio_data`
INNER JOIN `kp_types` ON `db565263480`.`kp_bio_data`.`kp_id` = `db565263480`.`kp_types`.`id`
INNER JOIN `clinic_visit` ON `db565263480`.`clinic_visit`.`uuid` = `db565263480`.`kp_bio_data`.`uuid`;
END;//

delimiter ;

这是mysql中的测试用例

mysql> delimiter //
mysql>
mysql> CREATE PROCEDURE `client_clinical_visit`()
-> DETERMINISTIC
-> COMMENT 'Client clinical visit '
-> BEGIN
-> SELECT
-> `db565263480`.`kp_bio_data`.`uuid` AS `uuid`,
-> `db565263480`.`kp_bio_data`.`firstname` AS `firstname`,
-> `db565263480`.`kp_bio_data`.`lastname` AS `lastname`,
-> `db565263480`.`kp_bio_data`.`id` AS `kp_bio_data_id`,
-> `db565263480`.`kp_bio_data`.`tel` AS `tel`,
-> `db565263480`.`kp_bio_data`.`gender` AS `gender`,
-> `db565263480`.`kp_bio_data`.`marital_status` AS `marital_status`,
-> `db565263480`.`kp_bio_data`.`education_level` AS `education_level`,
-> `db565263480`.`kp_bio_data`.`place_of_birth` AS `place_of_birth`,
-> `db565263480`.`kp_types`.`id` AS `kp_types_id`,
-> `db565263480`.`kp_types`.`Name` AS `name`,
-> `db565263480`.`kp_types`.`Abbrv` AS `abbrv`,
-> `db565263480`.`clinic_visit`.`disc_no` AS `disc_no`
-> FROM
-> `kp_bio_data`
-> INNER JOIN `kp_types` ON `db565263480`.`kp_bio_data`.`kp_id` = `db565263480`.`kp_types`.`id`
-> INNER JOIN `clinic_visit` ON `db565263480`.`clinic_visit`.`uuid` = `db565263480`.`kp_bio_data`.`uuid`;
-> END;//
Query OK, 0 rows affected (0.08 sec)

关于MySQL 说 : Documentation #1064 - You have an error in your SQL syntax; on Stored Procedure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29539393/

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