Re: What is the difference between these queries

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Re: What is the difference between these queries
Дата
Msg-id
9830.1302619571@sss.pgh.pa.us
Ответ на
Список
Дерево обсуждения
What is the difference between these queries salah jubeh <s_jubeh@yahoo.com>
Re: What is the difference between these queries tv@fuzzy.cz
Re: What is the difference between these queries Tom Lane <tgl@sss.pgh.pa.us>
Re: What is the difference between these queries tv@fuzzy.cz
tv@fuzzy.cz writes:
>> Query1
>> -- the first select return 10 rows
>> SELECT a, b
>> FROM table1 LEFT JOIN table2 on (table1_id = tabl2_id)
>> Where table1_id NOT IN (SELECT DISTINCT table1_id FROM table3)
>> EXCEPT
>> -- this select return 5 rows
>> SELECT a, b
>> FROM table1 LEFT JOIN table2 on (table1_id = tabl2_id)
>> Where table1_id NOT IN (SELECT DISTINCT table1_id FROM table3)
>> and  b ~* 'pattern'
>> -- the result is 5 rows
>> 
>> Query2
>> --this select return 3 rows
>> SELECT a, b
>> FROM table1 LEFT JOIN table2 on (table1_id = tabl2_id)
>> Where table1_id NOT IN (SELECT DISTINCT table1_id FROM table3)
>> and  b !~* 'pattern'
>> 
>> Why query1 and query2  return different set. note that query two return a
>> subset
>> of query1

> Those queries obviously are not equivalent - the regular expression is
> applied to different parts of the query.

Not sure I buy that ... personally I was wondering whether there were
some null values of b.

			regards, tom lane
В списке pgsql-general по дате отправления
От: tomas@tuxteam.de
Дата:
От: tv@fuzzy.cz
Дата:
FAQ