join if there, blank if not

Поиск
Список
Период
Сортировка
От Gary Stainburn
Тема join if there, blank if not
Дата
Msg-id 01BFEC1E.FF0A43A0@garys.ringways.co.uk
обсуждение исходный текст
Ответы Re: join if there, blank if not  (Jacques Williams <jacques@jacqro.COM>)
Список pgsql-sql
Hi all,

I just can't get my head round this one so I hope one of you can.

I've got two tables, one holding phone calls, and another holding phone numbers.

I want to do a select where if the number in the calls table exists 
in the numbers table, the description is included otherwise the 
description field is blank.

Unfortunately, using the select I've tried, if the number is not on 
the one of the tables, it's ignored.

Calls table
cdate date
ctime time
cextn char(3)
cnumber x(12)

Numbers table

nnumber x(12)
ndesc x(30)

Select I tried.

select c.cdate, c.ctime, c.cextn, c.cnumber n.ndesc 
from calls c, numbers n where c.cnumber = n.nnumber;

-----------------------------------------
Gary Stainburn.
Work: http://www.ringways.co.uk mailto:gary.stainburn@ringways.co.uk
REVCOM: http://www.revcom.org.uk mailto:gary.stainburn@revcom.org.uk
-----------------------------------------
Murphy's Laws: (327) The minute before the engineer arrives, the printer starts working.
-----------------------------------------



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

Предыдущее
От: "Jean-Marc Libs"
Дата:
Сообщение: Re: SERIAL type does not generate new ID ?
Следующее
От: Abdul Karim
Дата:
Сообщение: importing in sql