Geeks Talk

Prepare for your Next Interview




Using LIKE operator in multiple condition

This is a discussion on Using LIKE operator in multiple condition within the SQL forums, part of the Databases category; If we have multiple conditions to check, can we use like operator? eg where empid like ('123%') or like ('23%')?...


Go Back   Geeks Talk > Databases > SQL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 11-23-2007
Junior Member
 
Join Date: Oct 2007
Location: NOIDA
Posts: 10
Thanks: 0
Thanked 3 Times in 3 Posts
Sant_parkash is on a distinguished road
Using LIKE operator in multiple condition

If we have multiple conditions to check, can we use like operator?
eg where empid like ('123%') or like ('23%')?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-23-2007
Expert Member
 
Join Date: Apr 2007
Location: Bangalore
Posts: 462
Thanks: 23
Thanked 57 Times in 56 Posts
susarlasireesha is on a distinguished road
Re: Using LIKE operator in multiple condition

The LIKE operator is used in character string comparisons with
pattern matching.

If empid is defined as varchar Then
select * from emp where empid like '123%'
retrieve records of emp where empid starts with 123
select * from emp where empid like '23%'
retrieve records of emp where empid starts with 23
Reply With Quote
  #3 (permalink)  
Old 11-24-2007
Moderator
 
Join Date: Sep 2007
Location: Chennai, INDIA
Posts: 406
Thanks: 2
Thanked 157 Times in 81 Posts
sridharrganesan will become famous soon enoughsridharrganesan will become famous soon enough
Re: Using LIKE operator in multiple condition

Like operator is used to retrieve records starting with the alphabet or numeric specified as the condition. For example,

Select * from emp where emp_name like 'Joh%'

This statement will retrieve the records where the employee name starts with "Joh"
Reply With Quote
  #4 (permalink)  
Old 11-26-2007
Moderator
 
Join Date: Jun 2007
Location: Bangalore,India
Posts: 1,483
Thanks: 8
Thanked 128 Times in 115 Posts
debasisdas will become famous soon enoughdebasisdas will become famous soon enough
Re: Using LIKE operator in multiple condition

LIKE operator is used for pattern matching you can combine multiple statments for different conditions using logical operators.
Reply With Quote
  #5 (permalink)  
Old 11-29-2007
Junior Member
 
Join Date: Nov 2006
Location: mumbai
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
mehta_hetal is on a distinguished road
Re: Using LIKE operator in multiple condition

u can combine like operator in multiple condition

for eg. where (name like 'abc%' or name like 'pqr%');
Reply With Quote
Reply

  Geeks Talk > Databases > SQL


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Output without the JOIN condition. How is it possible ? Geek_Guest SQL 5 11-02-2007 01:17 PM
Calling action on condition basis Prafullan QTP 2 11-01-2007 01:24 AM
Test Condition reks_209 Testing Templates 3 09-14-2007 04:18 AM
I want to tune four tables and 5 joins condition Caleb Sima and Vincent Li Oracle 2 06-29-2007 09:19 AM
How do I use a input variable inside like condition BharaniAditya123 Oracle 1 06-12-2007 02:14 AM


All times are GMT -4. The time now is 02:13 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved