Avatar of Coast Line
Coast Line
Flag 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

Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
slightwv (䄆 Netminder)

8/22/2022 - Mon
SOLUTION
D B

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
slightwv (䄆 Netminder)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Coast Line

ASKER
after the first query i am doing this

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

Open in new window

Coast Line

ASKER
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

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?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy