SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to use 'like' and 'substr' together
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chulz90
Starting Member

Indonesia
26 Posts

Posted - 04/08/2013 :  00:19:56  Show Profile  Reply with Quote
hello..

i've some trouble in my query. i just want to know the right one from this query below

i know the simple query is:
select * from rspi_do where do_number like '%RS%';


but i want to know how use like and substr ???

select * from rspi_do where do_number like '%substr(RS-DI-02-00002,1,2)%';
but teh result is nothing, i want to know where's the right one???

can i use like and substr together?????

thank's for helping

bandi
Flowing Fount of Yak Knowledge

India
2223 Posts

Posted - 04/08/2013 :  01:45:45  Show Profile  Reply with Quote
select * from rspi_do where do_number like '%'+substring(RS-DI-02-00002,1,2)+'%';
Go to Top of Page

chulz90
Starting Member

Indonesia
26 Posts

Posted - 04/08/2013 :  02:20:33  Show Profile  Reply with Quote
quote:
Originally posted by bandi

select * from rspi_do where do_number like '%'+substring(RS-DI-02-00002,1,2)+'%';




still error
T___T
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2223 Posts

Posted - 04/08/2013 :  02:29:34  Show Profile  Reply with Quote
which error? Is it error or incorrect result?
Go to Top of Page

chulz90
Starting Member

Indonesia
26 Posts

Posted - 04/08/2013 :  03:40:07  Show Profile  Reply with Quote
it says error syntax

but i've founded finally :D

select * from rspi_do where do_number1,2 like '%'||substr(RS-DI-02-00002,1,2)||'%';

thank's bandi for response
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2223 Posts

Posted - 04/09/2013 :  00:29:30  Show Profile  Reply with Quote
quote:
Originally posted by chulz90

it says error syntax

but i've founded finally :D

select * from rspi_do where do_number1,2 like '%'||substr(RS-DI-02-00002,1,2)||'%';

thank's bandi for response



I think you are working on Oracle/DB2... My solution is for SQL Server..
Thats why you got the error...

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000