Re: [SQL] Extracting hostname from URI column

2007-09-12 Thread Alvaro Herrera
Paul Lambert wrote:
> Andrej Ricnik-Bay wrote:
>
>> Plain regex The key are the parenthesis () ...
>> basically it will omit ANYTHING + two slashes at the beginning
>> of a string.  Then it will match everything BUT a slash, and as
>> much of that as possible since regex are greedy by default
>> (hence the host name he was looking for) ... and everything
>> AFTER a slash will be omitted.
>> Cheers,
>> Andrej
> Thanks - that makes a bit more sense. I'm in the middle of reading chapter 
> 9.3.7 of the manual - POSIX Regular Expressions - which I'm assuming is 
> dealing with this, so it's looking clearer.

A very good resource on regular expressions is "Mastering Regular
Expressions" by Jeffrey Friedl, now in its third edition:
http://www.oreilly.com/catalog/regex3/

I read the first ed. years ago and it was very illuminating.

-- 
Alvaro Herrera  Developer, http://www.PostgreSQL.org/
"Acepta los honores y aplausos y perderĂ¡s tu libertad"

---(end of broadcast)---
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate


Re: [SQL] Simple Query?

2007-09-12 Thread Osvaldo Rosario Kussama

Koen Bok escreveu:

I am doing some optimization on our search, but I need some advise...

table: item

idname
--
1iPod
2Zune
3Walkman

table: search_item

id_searchid_item
--
11
12
13
22
23
31
33


Now what I want to have is the items that match with id_search 1 and 2 
and 3. Therefore I use the following SQL query.


SELECT * FROM item WHERE id IN
(SELECT id_item FROM search_item WHERE id_search=1 AND id_item IN
(SELECT id_item FROM search_item WHERE id_search=2 AND id_item IN
(SELECT id_item FROM search_item WHERE id_search=3)));

This should only return id_item 3. Would this be the best SQL query to 
get this result? I have the feeling there should be something better, 
but I cannot find it. Anyone has a hint?






SELECT * FROM item WHERE id IN
(SELECT id_item FROM search_item WHERE id_search=1
 INTERSECT
 SELECT id_item FROM search_item WHERE id_search=2
 INTERSECT
 SELECT id_item FROM search_item WHERE id_search=3);

Osvaldo

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly