Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8717773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:22:25+00:00 2026-06-13T06:22:25+00:00

how can I do an if statement to check if the column value is

  • 0

how can I do an if statement to check if the column value is equal to an input value a user entered

I have a table called Tasks and a primary key called TaskID. How would the “if” condition look like if I am trying to compare an id a user entered, to the TaskID column

basically I am trying to do if(TaskID = 599) insert values

I have tried this so far:

if ((select TaskID from MyDB.dbo.Tasks where TaskID=599) = 599)
begin
insert into MyDB.dbo.Tasks (Concluded)
Values (1)
end

however I don’t think it has the result I want. It keeps creating a new task in stead.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:22:26+00:00Added an answer on June 13, 2026 at 6:22 am

    Try this

    IF EXISTS (SELECT 1 FROM task WHERE taskid=599)
        UPDATE MyDB.dbo.Tasks SET concluded = 1 WHERE taskid=599
    ELSE
        INSERT INTO MyDB.dbo.Tasks (concluded) VALUES (1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table: As you can see index_lang is a unique key
As you know, in Eclipse you can turn on Unnecessary 'else' statement check that
I know that I can use the statement: [string1 rangeOfString:compareString].location!=NSNotFound to check if a
Can an if statement have more than one then statements? # this works a
I have an Postgre database and a table called my_table. There are 4 columns
In a SQL Server table I have the following 2 columns: RowId : primary
I have a table with 1 column textField. Our version of mysql won't allow
I have a table with several columns. Columns 1and 2 can contain any of
I have a SQL Server 2005 table that has a string column in which
I can't make a Select on a table in a sqlite database. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.