0
我在MySQL過程中有錯誤,因爲我試圖在'Where'參數中選擇多行。當我把'Where = param_oid'(檔案錶行的oid)放到整個過程中,但我想從檔案中返回幾行(所以不是調用表courrier_concerne_dossier中存在的檔案中的每個oid的過程)無論如何 - 我是試圖找到解決方案。子查詢在MySQL中返回多於1行where子句
有沒有簡單的方法來解決這個問題?
DROP procedure if exists `courrier_envoye_pickdossiers`;
DELIMITER $$
CREATE procedure `courrier_envoye_pickdossiers`(IN param_oid binary(16))
BEGIN
set param_oid = (select oid from courrier_envoye where numero_chrono_ordre = "2632" AND numero_chrono_annee = "2013" limit 1);
SELECT
CAST(concat(a.prefixe_numero,a.numero, " - ", a.date_ouverture) AS CHAR) as 'noet',
a.intitule as 'intitule',
(select nom from gta_geoptima_data.client as m where a.client_oid = m.oid) as 'no_client',
(select numero_client_abreviation from gta_geoptima_data.client as m where a.client_oid = m.oid) as 'sigle',
(select nom from gta_geoptima_data.client as m where a.client_oid = m.oid) as 'nom_raison',
(select intitule from gta_geoptima_data.direction_interne as m where a.direction_oid = m.oid) as 'service',
a.date_livraison as 'livraison'
FROM gta_geoptima_data.dossier as a
WHERE a.oid = (select dossier_oid from courrier_concerne_dossier where courrier_oid = param_oid);
END$$
call courrier_envoye_pickdossiers(null);
子查詢返回多個1行0.032秒
好吧,只需調整SELECT在WHERE子句中使用,因此它總是返回1行。考慮「LIMIT」,「DISTINCT」或其他邏輯,具體取決於返回的數據和數據。 –
也許我應該使用EXISTS? – boski