0
大家好!我從我的MySql存儲過程中得到了重複輸出的問題,當我在Web上看時,我的語法是正確的。請有人能幫助我嗎?這裏是我的代碼:在存儲過程中加入3個表中的重複輸出
DELIMITER $$
USE `xxxxxx`$$
DROP PROCEDURE IF EXISTS `VIEW_GCELC_DELEGATE_SP`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `VIEW_GCELC_DELEGATE_SP`(
)
BEGIN
SELECT lc_data.indicode, lc_indi.lastname, lc_indi.firstname, lc_org.orgname
FROM tb_gcelc_data AS lc_data
INNER JOIN tb_gcelc_orgreg AS lc_org ON lc_data.orgcode = lc_org.orgcode
INNER JOIN tb_gcelc_indireg AS lc_indi ON lc_data.orgcode = lc_indi.orgcode
WHERE lc_data.year = YEAR(CURDATE())
ORDER BY lc_org.orgname;
END$$
DELIMITER ;
這裏是輸出:
indicode lastname firstname orgname
379257 Testing Testing Company Number One
957914 Testing Testing Company Number One
729065 Testing Testing Company Number One
389915 Testing Testing Company Number One
652854 Testing Testing Company Number One
696817 Testing Testing Company Number One
469712 Testing Testing Company Number One
450179 Testing Testing Company Number One
966966 Testing Testing Company Number One
379257 Test Mode Testing Again Company Number One
957914 Test Mode Testing Again Company Number One
729065 Test Mode Testing Again Company Number One
389915 Test Mode Testing Again Company Number One
652854 Test Mode Testing Again Company Number One
696817 Test Mode Testing Again Company Number One
469712 Test Mode Testing Again Company Number One
450179 Test Mode Testing Again Company Number One
966966 Test Mode Testing Again Company Number One
379257 More Test More Company Number One
957914 More Test More Company Number One
729065 More Test More Company Number One
389915 More Test More Company Number One
652854 More Test More Company Number One
696817 More Test More Company Number One
469712 More Test More Company Number One
450179 More Test More Company Number One
966966 More Test More Company Number One
這是因爲環路輸出的很奇怪。
預先感謝您!
你可以顯示樣本數據嗎? – Jens 2014-10-27 08:34:10
也許我的眼睛失敗了,但在樣例輸出中沒有看到任何重複的行。 – jpw 2014-10-28 01:42:44
379257有3個輸出。名稱Testing Testing有9個輸出。 – Dennis 2014-10-29 02:14:26