SET @UserID_In = 1;
Select * FROM EarnedTransaction AS ETMain WHERE ETMain.UserID = @UserID_In
AND ETMain.ID = ( SELECT MAX(ID) FROM EarnedTransaction AS ETSub WHERE ETSub.UserID =
ETMain.UserID AND ETSub.TransactionType = 'Buying' AND ETSub.CompleteDate IS NULL )
AND ETMain.ID = ( SELECT MAX(ID) FROM EarnedTransaction AS ETSub WHERE ETSub.UserID =
ETMain.UserID );
退货34 15 Buying 1500 1428101231 1 2014-09-29 10:09:55
但:
SET @UserID_In = 1;
Delete FROM EarnedTransaction AS ETMain WHERE ETMain.UserID = @UserID_In
AND ETMain.ID = ( SELECT MAX(ID) FROM EarnedTransaction AS ETSub WHERE ETSub.UserID =
ETMain.UserID AND ETSub.TransactionType = 'Buying' AND ETSub.CompleteDate IS NULL )
AND ETMain.ID = ( SELECT MAX(ID) FROM EarnedTransaction AS ETSub WHERE ETSub.UserID =
ETMain.UserID );
返回:
[Err] 1064 - You have an error in your SQL syntax;
查看与您的 MySQL 服务器版本相对应的手册,以AS ETMain WHERE ETMain.UserID = @UserID_In
AND ETMain.ID = ( SELECT MAX(ID)
在第 1 行附近使用正确的语法