gpt4 book ai didi

mysql - 程序的多个结果集。如何只返回最后一个结果集?

转载 作者:行者123 更新时间:2023-11-30 23:00:26 24 4
gpt4 key购买 nike

我的程序返回 2 个结果集;我怎样才能只返回最后一个结果集?

我想“禁用”第一个 SELECT。

按照以下步骤操作。

问候;

CREATE DEFINER=`root`@`%` PROCEDURE `PR_LOGIN`( IN USER BIGINT, IN PASS CHAR(50), IN X_STORE INT, IN X_POINT_SALE INT, IN DATETI DATETIME, IN IP_ACCESS VARCHAR(20) )
BEGIN

DECLARE VAR_TOTAL INT;

DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;

START TRANSACTION;

SELECT
A.*,
@_USER_NAME:= B.USER_NAME,
@_STORE_DESCR:= C.STORE_DESCR,
@_POINT_SALE_DESCR:= D.POINT_SALE_DESCR
FROM
TB_USER_STORE AS A
INNER JOIN TB_USER AS B ON (A.ID_USER = B.ID_USER )
INNER JOIN TB_STORE AS C ON (A.ID_STORE = C.ID_STORE)
INNER JOIN TB_POINT_SALE AS D ON (A.ID_POINT_SALE = D.ID_POINT_SALE)
WHERE B.ID_USER = USER AND B.PASSWORD = PASS AND A.FLG_ACTIVE = 1 AND B.FLG_ACTIVE = 1 AND A.ID_STORE = X_STORE AND A.ID_POINT_SALE = X_POINT_SALE;

IF FOUND_ROWS() = 1 THEN
INSERT INTO TB_LOG_ACCESS (ID_USER, ID_STORE, ID_POINT_SALE, DT_ENT, DT_EXI, IP_ACCESS) VALUES( USER , X_STORE, X_POINT_SALE,DATETI,NULL, IP_ACCESS);
SELECT LAST_INSERT_ID() AS ID_LOG_ACCESS, USER AS USER_ID, @_USER_NAME AS USER_NAME, X_STORE AS ID_STORE, X_POINT_SALE AS POINT_SALE, @_STORE_DESCR AS STORE_DESCR, @_POINT_SALE_DESCR AS POINT_SALE_DESCR ;
END IF;

COMMIT;
END

最佳答案

如果您不想返回选择的结果,那么您可以:

  • put the values to a table using "insert into t1(f1) select ..."
  • put the values to a local variable using select field1 from table1 limit 1 into localVariable1;

关于mysql - 程序的多个结果集。如何只返回最后一个结果集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24317083/

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