{"action":"created","issue":{"url":"https://api.github.com/repos/tgriesser/knex/issues/716","labels_url":"https://api.github.com/repos/tgriesser/knex/issues/716/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/knex/issues/716/comments","events_url":"https://api.github.com/repos/tgriesser/knex/issues/716/events","html_url":"https://github.com/tgriesser/knex/issues/716","id":59320245,"number":716,"title":"Common table expressions in knex.js","user":{"login":"ericeslinger","id":255715,"avatar_url":"https://avatars.githubusercontent.com/u/255715?v=3","gravatar_id":"","url":"https://api.github.com/users/ericeslinger","html_url":"https://github.com/ericeslinger","followers_url":"https://api.github.com/users/ericeslinger/followers","following_url":"https://api.github.com/users/ericeslinger/following{/other_user}","gists_url":"https://api.github.com/users/ericeslinger/gists{/gist_id}","starred_url":"https://api.github.com/users/ericeslinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericeslinger/subscriptions","organizations_url":"https://api.github.com/users/ericeslinger/orgs","repos_url":"https://api.github.com/users/ericeslinger/repos","events_url":"https://api.github.com/users/ericeslinger/events{/privacy}","received_events_url":"https://api.github.com/users/ericeslinger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-28T02:15:13Z","updated_at":"2015-07-01T21:02:33Z","closed_at":null,"body":"I couldn't find an issue for this, but I apologize if this is a dupe (for some reason I think I may have asked this already).\r\n\r\nI'm using postgres, which has a handy-dandy common table expression syntax. I can do stuff like\r\n\r\n    with (select * from documents) as alldocs\r\n    select id from alldocs;\r\n\r\nNaturally that's a toy example, but this is a pretty useful tool for doing some of the queries I need to run. Right now I'm just doing Raws, which is a bummer when I want to set up the CTE preamble, but then use json formatted objects to dynamically query the thing in question.\r\n\r\nlike putting a `.where(opts)` in the middle of the query, which I now have to do manually with string interpolation and counting ?marks.\r\n"},"comment":{"url":"https://api.github.com/repos/tgriesser/knex/issues/comments/117822869","html_url":"https://github.com/tgriesser/knex/issues/716#issuecomment-117822869","issue_url":"https://api.github.com/repos/tgriesser/knex/issues/716","id":117822869,"user":{"login":"whitelynx","id":285264,"avatar_url":"https://avatars.githubusercontent.com/u/285264?v=3","gravatar_id":"","url":"https://api.github.com/users/whitelynx","html_url":"https://github.com/whitelynx","followers_url":"https://api.github.com/users/whitelynx/followers","following_url":"https://api.github.com/users/whitelynx/following{/other_user}","gists_url":"https://api.github.com/users/whitelynx/gists{/gist_id}","starred_url":"https://api.github.com/users/whitelynx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whitelynx/subscriptions","organizations_url":"https://api.github.com/users/whitelynx/orgs","repos_url":"https://api.github.com/users/whitelynx/repos","events_url":"https://api.github.com/users/whitelynx/events{/privacy}","received_events_url":"https://api.github.com/users/whitelynx/received_events","type":"User","site_admin":false},"created_at":"2015-07-01T21:02:33Z","updated_at":"2015-07-01T21:02:33Z","body":"Concerning compatibility, CTEs are supported by the following databases, [according to Wikipedia](https://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL#Common_table_expression):\r\n- IBM DB2 version 2\r\n- Microsoft SQL Server\r\n- Firebird 2.1\r\n- PostgreSQL 8.4+\r\n- Oracle 11g Release 2\r\n- CUBRID"}}