Wednesday, August 22, 2012

SQL- IN

The SQL IN operator providing multiple values in your WHERE clause.
This can provide very useful when you need to compare your value to a list of values.

Syntax-

SELECT * FROM table_name WHERE column_name IN (value1,value2,...)

Source Table - Master

Id    FirstName    LastName   
1    Fred            Jeddo
2    Tomer            homey
3    Homer            Lacto
4    Ozzy            dev
5    mer            Kumar

SELECT * FROM Master
WHERE LastName IN ('homey','dev','Kumar');



Result table-

Id    FirstName    LastName   
2    Tomer            homey
4    Ozzy             dev
5    mer                Kumar

You might have noticed that this returns the same result as the following SQL statement:

SELECT * FROM Individual
WHERE LastName = 'honey'
OR LastName = 'dev'
OR LastName = 'kumar';

0 comments:

Post a Comment

SQL BASIC

  • Sql-Overview
  • Sql-Sysntax
  • Sql-Normalization
  • RDBMS Concept
  • Sql-Data Type
  • Sql-Operator
  • Sql-Expression
  • Create database
  • Sql-Delete
  • Sql-Select
  • Sql-Create
  • Sql-Like
  • Sql-Join
  • Sql-Insert
  • Sql-Drop Table
  • Sql-Wild Card
  • Sql-Order By
  • Sql-Group By
  • Sql-Index
  • Not Null Constraints
  • Transaction Control
  • Sql-Transaction
  • Sql-In
  • Sql-Distinct
  • Check Constraint
  • Sql Alias
  • Sql-Primary
  • Sql-Where
  • Sql-Update
  • Sql-Alias
  • Sql-Top-Rownum
  • Primary key vs Unique key
  • SQL Interview Question
  • PL/SQL BASIC

  • Variable
  • Block Structure
  • Function
  • Procedure
  • Nested Blog
  • If Statement
  • While Loop
  • For Loop
  • SEO

  • Introduction Seo
  • Top Social Bookmarking List
  • Directory Submission List
  • Classified Ads
  • Key Word Research
  • Html

  • Introduction Html
  • Introduction Css
  • Introduction Java Script
  • Unix

  • Unix
  • Software Testing

  • Software Testing
  • Computer Network

  • Computer Network
  •