Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2017
    Posts
    1

    Unanswered: Simple SQL Syntax question

    Hi,

    I'm using PostGres 9.1

    This query works for me:
    select left('Hello', 3) from mytable

    This one doesn't:
    select left(myfield, 3) from mytable

    Am I missing something?

    Below is the error I see in pgAdmin

    Thank you

    ----------------


    ERROR: function left(text[], integer) does not exist
    LINE 1: select left(session_id,3)
    ^
    HINT: No function matches the given name and argument types. You might need to add explicit type casts.
    ********** Error **********

    ERROR: function left(text[], integer) does not exist
    SQL state: 42883
    Hint: No function matches the given name and argument types. You might need to add explicit type casts.
    Character: 8

  2. #2
    Join Date
    Nov 2003
    Posts
    2,993
    Provided Answers: 23
    Your column is an array, not a varchar. Which element of the array do you want to use?

    Also: it's Postgres or PostgreSQL - there is no capital G in the name
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •