By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,346 Members | 2,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,346 IT Pros & Developers. It's quick & easy.

The MySQL command LEFT() counterpart in PostgreSQL?

P: 13
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.

Dec 4 '06 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 534
I think this should work for you:
Expand|Select|Wrap|Line Numbers
  1. SELECT  substring(story, 1, 20)  FROM  table01;
Dec 5 '06 #2

P: 13
Thanks Michelb, it worked :)
Dec 12 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.