Link to home
Start Free TrialLog in
Avatar of Coast Line
Coast LineFlag for Canada

asked on

Merge two queries into one

I want to merge the query into one

select id
				from dbo.table1 with(nolock)
				where cid = 622
if recordfromabove neq form.value then proceed the follow code				
update table1
					set id = 22
					where cid = 	622		

Open in new window

SOLUTION
Avatar of D B
D B
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Coast Line

ASKER

after the first query i am doing this

<cfif GetInfo.id NEQ arguments.id> then update </cfif>

Open in new window

both the above are failing, if i try, think it like this

<cfquery name="getinfo">
select id
				from dbo.table1 with(nolock)
				where cid = 622
</cfquery>
<cfif GetInfo.id NEQ arguments.id>			
update table1
					set id = #arguments.id#
					where cid = 	622
</cfif>

Open in new window

Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

I see no need to select the id first then update.  A single update should work fine.

Can you post sample data and expected results based on the arguments.id value selected?