Re: limit with subselect

Поиск
Список
Период
Сортировка
От Sam Mason
Тема Re: limit with subselect
Дата
Msg-id 20080725103930.GK2572@frubble.xen.chris-lamb.co.uk
обсуждение исходный текст
Ответ на limit with subselect  ("A B" <gentosaker@gmail.com>)
Список pgsql-general
On Fri, Jul 25, 2008 at 12:02:23PM +0200, A B wrote:
> and I wish to get 20 lines from T  like this
>
> select id,a,b from T where id not in (select id from T2 where c=5) limit 20;
>
> but that does not seem to work. How can I get what I want? What 20
> records are selected is not important. I just need 20.

You've told us what you're expecting, but not what you're actually
getting so most responses (including this) are going to be guesses! More
information = better responses!


My guess is that you're not getting anything back at all because one of
the "id"s in T2 is null.  If that is the case, you need to change the
query to look like:

  SELECT id,a,b FROM t WHERE id NOT IN (
    SELECT id FROM t2 WHERE c=5 AND id IS NOT NULL)
  LIMIT 20;



  Sam

В списке pgsql-general по дате отправления:

Предыдущее
От: "A B"
Дата:
Сообщение: Re: limit with subselect
Следующее
От: Bill Moran
Дата:
Сообщение: Re: php + postgresql