Ask a Question related to Coldfusion Database Access, Design and Development.
-
alwaysconfused #1
two queries - one cfquery call
I'm trying to do the following in one single cfquery call. However, I'm having
trouble referencing "memberCount" in the Insert part of the statement. It
keeps saying invalid column name "memberCount".
How would I reference it correctly? Thanks.
<cfquery>
SELECT COUNT(1) AS memberCount
FROM groupMembers
WHERE groupId = #arguments.groupId#;
UPDATE groupNames
SET groupNumberOfMembers = memberCount
WHERE groupId = #arguments.groupId#;
</cfquery>
alwaysconfused Guest
-
cfquery cache stores failed queries
cfquery cache still stores failed queries. This was reported years ago... -
No escape character with dircect method call in cfquery
Hello, I found the follwing behavior when I tried to use a method call directly in a <cfquery>. In this case single quote characers will not be... -
Queries Of Queries Single Quote Problem
When using queries of queries I'm having the following issue. Select Company_ID From qry_MyQuery Where Company_NM = 'MyString''s' <----... -
Best way to call SQL queries
Hi All I know this might sound strange, but I'm doing an ecom site and I'm actually going to use an Access Db in the development stages, because... -
remote call procedure call failed
Also, it says error 1726 "remote call procedure call failed" Help, Unable to save username and password in XP Home edition. It allows me to... -
mpwoodward *TMM* #2
Re: two queries - one cfquery call
alwaysconfused wrote:
I think you'd have to do something like this--this is assuming SQL Server:> I'm trying to do the following in one single cfquery call. However, I'm having
> trouble referencing "memberCount" in the Insert part of the statement. It
> keeps saying invalid column name "memberCount".
>
> How would I reference it correctly? Thanks.
>
> <cfquery>
> SELECT COUNT(1) AS memberCount
> FROM groupMembers
> WHERE groupId = #arguments.groupId#;
>
> UPDATE groupNames
> SET groupNumberOfMembers = memberCount
> WHERE groupId = #arguments.groupId#;
> </cfquery>
>
>
DECLARE @memberCount int
SELECT @memberCount = COUNT(1)
FROM groupMembers
WHERE groupId = #arguments.groupId#
UPDATE groupNames
SET groupNumberOfMembers = @memberCount
WHERE groupId = #arguments.groupId#
I can't test that at the moment but I think that should get you rolling.
Matt
--
Matt Woodward
[email]mpwoodward@gmail.com[/email]
Team Macromedia - ColdFusion
mpwoodward *TMM* Guest
-
Ali Soylu #3
Re: two queries - one cfquery call
How about:
UPDATE groupNames
SET groupNumberOfMembers = (SELECT COUNT(1) FROM groupMembers WHERE
groupID=#arguments.groupId# )
WHERE groupID = #arguments.groupId#;
or evenbetter , if you wanna do all groups:
UPDATE groupNames
SET groupNumberOfMembers = (SELECT COUNT(1) FROM groupMembers WHERE
groupMembers.groupID =groupNames.groupID )
ALi
Ali Soylu Guest
-
Dan Bracuk #4
Re: two queries - one cfquery call
Here is my suggestion
<cfquery name="abc">
alter table groupnames
drop column groupnumberofmembers
</cfquery>
<cfquery>
select groupname count(groupname) as membercount
from groupmembers join groupnames using (groupid)
where groupid = #arguments.groupid#
group by groupid
</cfquery>
syntax varies with different databases.
Dan Bracuk Guest



Reply With Quote

