【发布时间】:2019-07-02 02:33:02
【问题描述】:
我将以下内容放入 sqlfiddle 的 Schema 面板中:
CREATE TABLE tb_patient (
`idPatient` INTEGER,
`prenomPatient` VARCHAR(12),
`nomPatient` VARCHAR(6)
)//
INSERT INTO tb_patient
(`idPatient`, `prenomPatient`, `nomPatient`)
VALUES
('267', 'Marie Claude', 'CARRIE'),
('268', 'Marie Claude', 'CARRIE')//
create procedure findTwins()
begin
declare getNom varchar(40);
declare getPrenom varchar(40);
declare getId int default 1;
declare getId2 int default 1;
if(select count(*) from tb_patient group by nomPatient,prenomPatient having count(*)=2 limit 1)
then
select nomPatient,prenomPatient into getNom,getPrenom from tb_patient group by nomPatient,prenomPatient having count(*)=2 limit 1;
set getId=(select min(idPatient) from tb_patient where nomPatient=getNom and prenomPatient=getPrenom);
set getId2=(select max(idPatient) from tb_patient where nomPatient=getNom and prenomPatient=getPrenom);
select concat(getNom,' ',getPrenom,' ',getId,' ',getId2) as Patient;
end if;
end//
我从分隔符菜单中选择了//,并成功构建了架构。
然后我输入:
CALL FindTwins
在查询面板中。当我尝试运行查询时,我收到了错误消息:
MySQL 的查询面板中不允许使用 DDL 和 DML 语句;只允许 SELECT 语句。将 DDL 和 DML 放在架构面板中。
如果我不能在 查询面板?
【问题讨论】:
标签: mysql sql stored-procedures sqlfiddle