我可以在MySQL的同一选择查询中将多个列选择到多个变量中吗?
例如:
DECLARE iId INT(20); DECLARE dCreate DATETIME; SELECT Id INTO iId, dateCreated INTO dCreate FROM products WHERE pName=iName;
正确的语法是什么?
您的语法不太正确:您需要按顺序在INTO之前列出字段,并在以下列出相应的目标变量:
SELECT Id, dateCreated INTO iId, dCreate FROM products WHERE pName = iName