Inject rows into query resultes

From: Alex Magnum <magnum11200(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Inject rows into query resultes
Date: 2015-09-22 22:22:50
Message-ID: CA+cR4zdzOpFjRf6OaeEnjmS3w9tYi6b7Zy5JVjLL62e+USJwpw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
I am having a problem where I need to inject rows into a query result. That
is

I have a list of add records, lets say car listings which I select from a
table. The order of the results are given either by the user or
default/initial.

I now want to inject featured car adds after every 5th record. (coming from
the same table)

Right now, I am doing this on the PHP just calling the query twice but I am
wondering if there is a way to only run one query.

The main problem is that
a) i am using paging so the original listing should not be affected
b) the injected records should not be in the results returned for the
current page.

Any one having an idea how to solve that?

Thanks
Alex

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2015-09-22 23:05:30 Re: Inject rows into query resultes
Previous Message Alvaro Herrera 2015-09-22 21:57:38 Re: numeric data type