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

  • SEARCH
  • Home
  • 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 6978997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:49:47+00:00 2026-05-27T17:49:47+00:00

DECLARE vote_id INT; select id from votes where votes.question_id = question_id and vote_type_id =

  • 0
DECLARE vote_id INT;
    select id from votes where votes.question_id = question_id and vote_type_id = 3 into vote_id;

    if vote_id is null then
      ...do A
    else
      ...do B
    end if;

the condition should be true and execute A part of code but always execute B part.
How to use select with if statement? Thank you very much.

  • 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-05-27T17:49:47+00:00Added an answer on May 27, 2026 at 5:49 pm

    try select id from votes where votes.question_id = question_id and votes.vote_type_id = 3 into vote_id;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

DECLARE @table table(XYZ VARCHAR(8) , id int) INSERT INTO @table SELECT '4000', 1 UNION
declare fName varchar2(255 char); begin SELECT x.constraint_name into fName FROM all_constraints x JOIN all_cons_columns
declare @t1 Table ( a1 int ) insert into @t1 select top 10 AnimalID
declare @top int set @top = 5 select top @top * from tablename Is
DECLARE @OrdersTemp TABLE ( OrderId UNIQUEIDENTIFIER ) INSERT INTO @OrdersTemp SELECT ord.Id FROM Orders
declare begin for i in (select * from emp) loop if i.sal=1300 then update
declare @t table ( id int, SomeNumt int ) insert into @t select 1,10
declare @node int = 9044; DECLARE @sqlCommand NVARCHAR(MAX) = ( 'SELECT * FROM [@node].[database_name].dbo.table_name'
DECLARE @TotalMaxQty int SET @TotalMaxQty = 1000 SELECT PKId ,Qty FROM dbo.Sales PKId Qty
DECLARE @T INT EXEC('SELECT @T = count(user_id) FROM ( .. .. .. )') PRINT

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.