The MySQL command LEFT() counterpart in PostgreSQL?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Paks
    New Member
    • Dec 2006
    • 13

    The MySQL command LEFT() counterpart in PostgreSQL?

    Hello,
    I have a quick little question about the MySQL-command LEFT(columnName ,int).
    My question is if there's a counterpart in PostgreSQL for this command and what it is?

    What I want to do is take the first specified amount of signs in a text-column and print them out.
    For example:

    Instead of printing out all information in a text-column...
    SELECT story FROM table01;
    Once upon a time in a land far far away lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec eget libero eget pede rutrum iaculis.

    I want to be able to specify the number of signs printed...
    SELECT LEFT(story, 20) FROM table01; // this is the MySQL-cmd "LEFT"
    Once upon a time in

    Is this possible to do in PostgreSQL? And what is the command for it in that case?

    I'm a total newb when it comes to PostgreSQL and my earlier knowledge of MySQL is limited, unfortunately :/

    So I would be thankful for any help.

    //Paks
  • michaelb
    Recognized Expert Contributor
    • Nov 2006
    • 534

    #2
    I think this should work for you:
    Code:
    SELECT  substring(story, 1, 20)  FROM  table01;

    Comment

    • Paks
      New Member
      • Dec 2006
      • 13

      #3
      Thanks Michelb, it worked :)

      Comment

      Working...