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 7429219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:56:03+00:00 2026-05-29T08:56:03+00:00

a true IF…THEN statement would be useful here, but I am not aware of

  • 0

a true IF…THEN statement would be useful here, but I am not aware of one. I have the user passing in 2 parameters (cfk_in and senr_in) into my query, and based on whether the param is Y or N, I will change my query, here is my current query:

select a.course_id, a.topic_code
from course_sections a,
 statuses b
where a.course_id = b.course_id
  and term = upper('2010FALL')
  and status = 'P' and pos = 1

So this is pretty simple and would give me all sections and topic codes for a particular term. If the user passes in both params as ‘N’, I would like to just keep it at the above query. If the user passes in cfk_in = ‘Y’ and senr_in = ‘N’ then I would like to add “and a.topic_code = ‘CFK%'”, and like wise if the user passes in cfk_in = ‘N’ and senr_in = ‘Y’, I would like to add “and a.topic_code = ‘SENR'”. I am not allowing them to pass both in as ‘Y’.

Is there a way to do this in one query? Thanks for the help.

  • 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-29T08:56:04+00:00Added an answer on May 29, 2026 at 8:56 am

    It’s quite simple:

    [your query...]
    and ((cfk_in = 'N' and senr_in = 'N') or
         (cfk_in = 'Y' and senr_in = 'N' and a.topic_code like 'CFK%') or
         (cfk_in = 'N' and senr_in = 'Y' and a.topic_code = 'SENR'))
    

    This will also disallow passing both parameters as 'Y', as that would return no results. If cfk_in and senr_in aren’t actual fields in your table, then mark them as bind variables:

    [your query...]
    and ((:cfk_in = 'N' and :senr_in = 'N') or
         (:cfk_in = 'Y' and :senr_in = 'N' and a.topic_code like 'CFK%') or
         (:cfk_in = 'N' and :senr_in = 'Y' and a.topic_code = 'SENR'))
    

    Or with Java:

    [your query...]
    and ((? = 'N' and ? = 'N') or
         (? = 'Y' and ? = 'N' and a.topic_code like 'CFK%') or
         (? = 'N' and ? = 'Y' and a.topic_code = 'SENR'))
    

    … binding cfk_in at indexes 1, 3, 5, and senr_in at indexes 2, 4, 6

    N.B: I think you meant to filter a.topic_code like 'CFK%', not a.topic_code = 'CFK%'

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

Sidebar

Related Questions

Required is the true language version of the OS, not the user interface language
1) Is it true that if you would like to have your custom dialogues
True or not: We should always use proper capitalization and never put whole sentences
I want a true deep copy. In Java, this was easy, but how do
Sometimes I have a true colored image, by using dithering algorithm, I can reduce
Is it true that after a user signs up, a sql table is create
while True: mess = raw_input('Type: ') //other stuff While user doesn't type anything, I
If true it will send an error message to the user. If false delivery
Is the following true? When the app is about to quit, it's not necessary
I have some confusing True and False questions I wish anyone answers them and

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.