View previous topic :: View next topic
|
Author |
Message |
SumeetDuseja
New User
Joined: 12 Jul 2009 Posts: 9 Location: Pune
|
|
|
|
There is one table EMP having record as below
Table EMP
Code: |
EMPno. Name pos_code
---------------------------------
1 GEORGE SA_MGR
2 CHRIS SABMGR
3 ROBERT SAAMGR
4 DICK SA_EMP
5 JAMES SABEMP |
Now I want records of only those employee whose POS_CODE start with SA_ only.
If I write query like as below
select * from EMP where pos_code like 'SA_%'
then it will also fetch the emp record whoose pos_code is SABMGR or SAAMGR also because LIKE operatot SQL assume _ as a any single occurance of charecter but I want this _ itself to be match as a data.
Please help me to achieve it.
|
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Maybe you can use SUBSTR(pos_code,1,3) = 'SA_ ' |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
where Col1 LIKE 'SA+_%' ESCAPE '+' |
|
Back to top |
|
|
|