convert query from mysql

From: "Mike Andrewjeski" <Mike(dot)Andrewjeski(at)businesswire(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: convert query from mysql
Date: 2013-12-17 20:44:57
Message-ID: 52B0475A.A009.0041.1@businesswire.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


Hi all,

psql newbie here. I'm working to convert a mysql query written in ruby to using postgres as our database is now postgres 9.2

Here's the mysql query:

select nodes.name, GROUP_CONCAT(node_groups.name) from node_groups,
node_group_memberships, nodes where nodes.id =
node_group_memberships.node_id and node_groups.id =
node_group_memberships.node_group_id and nodes.name IN (SELECT name
from nodes) group by nodes.name order by nodes.name")
What I'm having an issue with is the IN Clause. Not sure how to do that in psql.

This is what I've got so far any comments are more than welcome:

select nodes.name, node_groups.name from node_groups, node_group_memberships, nodes where nodes.id=node_group_memberships.node_id and node_groups.id=node_group_memberships.node_group_id ;

Please Note:

The information in this Business Wire e-mail message, and any files transmitted with it, is confidential and may be legally privileged. It is intended only for the use of the individual(s) named above. If you are the intended recipient, be aware that your use of any confidential or personal information may be restricted by state and federal privacy laws. If you, the reader of this message, are not the intended recipient, you are hereby notified that you should not further disseminate, distribute, or forward this e-mail message. If you have received this e-mail in error, please notify the sender and delete the material from any computer.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Kevin Grittner 2013-12-17 21:36:10 Re: convert query from mysql
Previous Message angelina410329 2013-12-17 09:37:04 回复: How to Recover iPhone Contacts You Lost Somehow?