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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:57:23+00:00 2026-06-13T19:57:23+00:00

I am writing a query in which where clause have IN clause and there

  • 0

I am writing a query in which where clause have IN clause and there are large number of values in this IN clause , I want to fetch the result such that if there is no value exist in table for value given in IN clause then a raw containing 0 or null should return for that value. for example..

select age,sex,date_joining from emp where name IN ('amit','john','paul','dilip')

Now assume for this query ,data for john and paul does not exist in database then result should be like below..

21    male   21-AUG-2011
null  null   null
null  null   null
25    male   9-aug-2010

we can also have 0 instead of null if null is not possible

Thanks…

  • 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-13T19:57:25+00:00Added an answer on June 13, 2026 at 7:57 pm
    select  filter.name
    ,       emp.age
    ,       emp.sex
    ,       emp.date_joining 
    from    (
            values ('amit'), ('john'), ('paul'), ('dilip')
            ) filter(name)
    left join    
            emp
    on      emp.name = filter.name
    

    Live example at SQL Fiddle.

    For older values of SQL Server, replace the line with values by:

    from    (
                      select 'amit'
            union all select 'john'
            union all select 'paul'
            union all select 'dilip'
            ) filter(name)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing the query to count the number of distinct values in the
Im writing sql query and i have issue which i cannot fix. I'm trying
I am writing an SQL query in which that I will need to perform
I have this query which works but when I try to write the equivalent
I have a statement that needs writing (with generic names for stuff, since this
I have a table structure that looks like this: Columns: Account Number Service Code
I have a db table that looks like this: State is a number that
I am having trouble writing a HQL query which uses a where in clause.
I am writing a query in which I have to get the data for
I am writing a query which needs to return all child entries (and their

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.