Skip to content
Advertisement

How to update columns only if argument is equal to specific value?

I have query that should update columns only if argument is equal 1. Here is example:

I would like to move this SQL query to stored procedure. How I can achive the same process with SQL code only? Instead of <cfif form.status eq 1> title = @title,</cfif> how that can be replaced with SQL code? I use Sybase database and ColdFusion 2016. This code above should be moved to stored procedure.

Advertisement

Answer

I think you want a case expression, something like this:

In a stored procedure, you would probably use parameters:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement