Re: [SQL] Substring

2009-09-07 Thread Fernando Hevia
> > > > Given that tablename is "voipdb"; I wonder if OP really > wants to write > > a query that finds the row where argument to function > matches the most > > number of leading characters in "prefix". > > > > If voipdb table contains: ab, abc, def, defg; then calling > function > > wit

Re: [SQL] Substring

2009-09-04 Thread Raj Mathur
On Saturday 05 Sep 2009, Frank Bax wrote: > Raj Mathur wrote: > > On Saturday 05 Sep 2009, bilal ghayyad wrote: > >> I have an sql script function that take one text parameter "funct > >> (text)", what I need to do is the following: > >> > >> If the parameter name is string and its value was for ex

Re: [SQL] Substring

2009-09-04 Thread Frank Bax
Raj Mathur wrote: On Saturday 05 Sep 2009, bilal ghayyad wrote: I have an sql script function that take one text parameter "funct (text)", what I need to do is the following: If the parameter name is string and its value was for example "abcd" then I need to do a query based on ab and then base

Re: [SQL] Substring

2009-09-04 Thread Raj Mathur
On Saturday 05 Sep 2009, bilal ghayyad wrote: > I have an sql script function that take one text parameter "funct > (text)", what I need to do is the following: > > If the parameter name is string and its value was for example "abcd" > then I need to do a query based on ab and then based on the abc

[SQL] Substring

2009-09-04 Thread bilal ghayyad
Hello; I have an sql script function that take one text parameter "funct (text)", what I need to do is the following: If the parameter name is string and its value was for example "abcd" then I need to do a query based on ab and then based on the abc, how? Example: SELECT * from voipdb where

[SQL] SQL substring

2003-11-12 Thread Guy Korland
Hi, How can I compare two fields if one is a substring of the other? Something like: ... WHERE StringA like '%' + StringB + '%'; Thanks, Guy Korland ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropri

Re: [SQL] SQL substring

2003-11-12 Thread Bruno Wolff III
On Wed, Nov 12, 2003 at 11:38:31 -0300, Franco Bruno Borghesi <[EMAIL PROTECTED]> wrote: > ... WHERE field1 LIKE '%' || field2 || '%' The first way won't work correctly if field2 has %s in it. > or > ... WHERE position(field2 in field1)>0 ---(end of broadcast)--

Re: [SQL] SQL substring

2003-11-12 Thread Franco Bruno Borghesi
... WHERE field1 LIKE '%' || field2 || '%' or ... WHERE position(field2 in field1)>0 On Wed, 2003-11-12 at 11:07, Guy Korland wrote: Hi, How can I compare two fields if one is a substring of the other? Something like: ... WHERE StringA like '%' + StringB + '%'; Thanks, Guy Korland --

Re: [SQL] substring ..

2000-12-20 Thread Jie Liang
Hi,there, I am not sure what is your question mean. However, if the type of datefoo is a timestamp then try: select foo from table where date(datefoo) = '2000-12-14'; select foo from table where datefoo::date = '2000-12-14'::date; select foo from table where substr(datefoo,1,10) = '2000-12-14';

Re: [SQL] substring ..

2000-12-19 Thread Karel Zak
On Tue, 19 Dec 2000, Jeff MacDonald wrote: > hi folks.. > > i want to do this to a datetime field.. > > select foo from table where substr(datefoo,1,11) = '2000-12-14'; And why not to_char()? Karel

Re: [SQL] substring ..

2000-12-19 Thread Robert B. Easter
Hehe, here is my tests with this: ctntest2=# SELECT create_date FROM users; create_date 2000-08-29 13:01:53-04 2000-08-27 20:04:41-04 2000-08-27 21:24:28-04 2000-08-30 09:51:16-04 2000-07-25 23:14:08-04 2000-07-25 23:14:08-04 2000-09-01 02:53:02-04 2000-07-2

Re: [SQL] substring ..

2000-12-19 Thread Tulio Oliveira
Jeff MacDonald wrote: > > hi folks.. > > i want to do this to a datetime field.. > > select foo from table where substr(datefoo,1,11) = '2000-12-14'; > > it returns no results yet.. > > select substr(datefoo,1,11) does return some values that say > 2000-12-14 > > any clues ? > > Jeff MacDon

Re: [SQL] substring ..

2000-12-19 Thread Joel Burton
> i want to do this to a datetime field.. > > select foo from table where substr(datefoo,1,11) = '2000-12-14'; > > it returns no results yet.. > > select substr(datefoo,1,11) does return some values that say > 2000-12-14 Ummm... because '2000-12-14' is a ten-character, not eleven character lo

Re: [SQL] substring ..

2000-12-19 Thread Josh Berkus
Jeff, > i want to do this to a datetime field.. > > select foo from table where substr(datefoo,1,11) = '2000-12-14'; > > it returns no results yet.. > > select substr(datefoo,1,11) does return some values that say > 2000-12-14 Well, for one it's not a string, it's a datetime field. WHy are y

Re: [SQL] substring ..

2000-12-19 Thread Stephan Szabo
On Tue, 19 Dec 2000, Jeff MacDonald wrote: > hi folks.. > > i want to do this to a datetime field.. > > select foo from table where substr(datefoo,1,11) = '2000-12-14'; > > it returns no results yet.. > > select substr(datefoo,1,11) does return some values that say > 2000-12-14 > > any clues

RE: [SQL] substring ..

2000-12-19 Thread Francis Solomon
Hi Jeff, '2000-12-14' is only 10 chars long. You're asking for an 11-char long substring to match a 10-char ... not going to happen! You can see this better if you do something like this ... select '@' || substr(datefoo,1,11) || '@' from table; ... and you'll get results like: @2000-12-14 @ S

[SQL] substring ..

2000-12-19 Thread Jeff MacDonald
hi folks.. i want to do this to a datetime field.. select foo from table where substr(datefoo,1,11) = '2000-12-14'; it returns no results yet.. select substr(datefoo,1,11) does return some values that say 2000-12-14 any clues ? Jeff MacDonald, ---