4

我在我的cfquery.

SET @rID = ( SELECT TOP 1 roleid
             FROM Roles
             WHERE RoleName = @rName AND appid = @appID
             ORDER BY Created DESC);

是否可以在@rID不必SELECT第二次运行查询的情况下进行检索?如:

<cfset varName = queryName.rID>

以上显然不起作用,但是还有其他方法可以从查询中返回变量吗?

4

1 回答 1

9

@rID您可以通过ing获得值,select而无需再次运行完整查询。

<cfquery name="qryRoleID">
    SET @rID = ( SELECT TOP 1 roleid
         FROM Roles
         WHERE RoleName = @rName AND appid = @appID
         ORDER BY Created DESC);
    SELECT @rID AS rID
</cfquery>
<cfdump var="#qryRoleID.rID#">
于 2012-10-17T13:19:23.183 回答