Re: select 3 characters
От | Jeff Eckermann |
---|---|
Тема | Re: select 3 characters |
Дата | |
Msg-id | 20030515221306.37113.qmail@web20809.mail.yahoo.com обсуждение исходный текст |
Ответ на | Re: select 3 characters (Josh Berkus <josh@agliodbs.com>) |
Список | pgsql-sql |
--- Josh Berkus <josh@agliodbs.com> wrote: > CJ - > > You might want to join the NOVICE list and post this > kind of question there, > should you have more. > > > Hi I need select the first 3 characters from a > table > > > > I try this but doesn't work > > > > "SELECT left(data,3) AS value FROM table;" > > > > i see the left function doesn't work what is the > similar function in > postgresql > > SUBSTR(data, 1, 3) > > See "Functions And Operators" in the online docs for > more. PostgreSQL lets you define your own functions, so you could do something like: CREATE OR REPLACE FUNCTION left(text, integer) RETURNS text AS ' SELECT substr($1, 1, $2); ' LANGUAGE 'SQL'; If you have a lot of code already written using the "left" function, that will save you from having to rewrite it. Look at "CREATE FUNCTION" in the "SQL Commands" section of the manual; also "Procedural Languages" in the "Programmers Guide". Do a search on "function overloading", so you will be able to define a function that works regardless of the datatypes fed to it. __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com
В списке pgsql-sql по дате отправления: