我想显示早班司机的详细信息。
delimiter //
create function dShift(n int)
returns varchar(128)
deterministic
begin
return (select driver.driver_no,driver_name,licence_no,address,d_age,salary
from driver,bus_driver as bd where bd.shift=n and bd.driver_no =
driver.driver_no);
end //
在你的函数中,返回类型是 varchar returns varchar(128)
。因此,它期望单个字符串作为输出。但是您返回 6 列作为输出。
可以使用以下方法获取列列表作为输出:
delimiter //
CREATE FUNCTION dShift (n INT)
BEGIN
SELECT driver.driver_no
,driver_name
,licence_no
,address
,d_age
,salary
FROM driver
JOIN bus_driver AS bd ON bd.driver_no = driver.driver_no
WHERE bd.shift = n;
END //