Re: does this require a stored procedure?

Поиск
Список
Период
Сортировка
От Manfred Koizar
Тема Re: does this require a stored procedure?
Дата
Msg-id p7mnbv4tn42is323v8ja9jd3orbrrcfcdr@4ax.com
обсуждение исходный текст
Ответ на does this require a stored procedure?  (Alex Rice <alrice@ARCplanning.com>)
Список pgsql-sql
On Thu, 8 May 2003 12:50:02 -0600, Alex Rice <alrice@ARCplanning.com>
wrote:
>Is it possible to rewrite this SQL query so it returns one row having  
>the columns title and contentType, instead of two rows with the sname  
>column? [...]
>
># SELECT rec_id, url, sname, sval FROM url, urlinfo
>WHERE url.rec_id = 1821
>AND url.rec_id = urlinfo.url_id
>AND sname in('title','Content-Type');

SELECT u.rec_id, u.url, t.sval AS title, c.sval AS "contentType" FROM url u     INNER JOIN urlinfo t        ON
(u.rec_id= t.url_id AND t.sname = 'title')     INNER JOIN urlinfo c        ON (u.rec_id = c.url_id AND c.sname =
'Content-Type')WHEREurl.rec_id = 1821;
 

Use LEFT JOINs if it's not sure that there is always a 'title' and a
'Content-Type'.

ServusManfred



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

Предыдущее
От: Larry Rosenman
Дата:
Сообщение: %ROWTYPE and insert
Следующее
От: Wei Weng
Дата:
Сообщение: index fragmentation