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

query translation

P: n/a
Hi,

I'm trying to translate from mysql to pgsql one query as below

SELECT DISTINCT name FROM table ORDER BY surname

Referring to mysql this query was working perfectly, however when I try use
this query with pgsql I didn't achieve result

What should I do?

Why that query doesn't work correctly with pgsql?
Aug 13 '05 #1
Share this Question
Share on Google+
4 Replies

P: n/a
In article <dd**********@nemesis.news.tpi.pl>,
"gniewosh" <ne**@inso.pl> wrote:
Hi,

I'm trying to translate from mysql to pgsql one query as below

SELECT DISTINCT name FROM table ORDER BY surname

Referring to mysql this query was working perfectly, however when I try use
this query with pgsql I didn't achieve result

What should I do?

Why that query doesn't work correctly with pgsql?


Well, what result are you getting for the MySQL vs PostgreSQL?

Are you sure the same data set is in both databases?

--
Available for Hire! http://amduus.com/Resumes/
Aug 13 '05 #2

P: n/a
> Well, what result are you getting for the MySQL vs PostgreSQL?
Are you sure the same data set is in both databases?


There is not a problem with data only with syntax of the sql language,
because as I written I have a query with is working perfectly in mysql. This
query is giving me a list of particular records from column name which are
ordered according to column surname. When I was try to use the same query
for pgsql I have problem, because the database never return me answer.

Aug 14 '05 #3

P: n/a
In article <dd**********@nemesis.news.tpi.pl>,
"gniewosh" <ne**@inso.pl> wrote:
Well, what result are you getting for the MySQL vs PostgreSQL?
Are you sure the same data set is in both databases?


There is not a problem with data only with syntax of the sql language,
because as I written I have a query with is working perfectly in mysql. This
query is giving me a list of particular records from column name which are
ordered according to column surname. When I was try to use the same query
for pgsql I have problem, because the database never return me answer.

Perhaps you need to add the field to the list of columns to return. I
have to say, when I sort on columns, it is always columns I plan to
display - so I have always had my ORDER BY in the column list of the
SELECT.

--
Available for Hire! http://amduus.com/Resumes/
Aug 14 '05 #4

P: n/a


gniewosh wrote:
Hi,

I'm trying to translate from mysql to pgsql one query as below

SELECT DISTINCT name FROM table ORDER BY surname


I got this on my postgreSQL database:
ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list

Then try
SELECT DISTINCT name, surname ORDER BY surname;

Regards

Sep 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.