Re: insert only if conditions are met?
От | Henry Ortega |
---|---|
Тема | Re: insert only if conditions are met? |
Дата | |
Msg-id | 2bffcc3305083108497ea6dcc6@mail.gmail.com обсуждение исходный текст |
Ответ на | insert only if conditions are met? (Henry Ortega <juandelacruz@gmail.com>) |
Ответы |
Re: insert only if conditions are met?
Re: insert only if conditions are met? |
Список | pgsql-sql |
What I am trying to do is
* Insert a record for EMPLOYEE A to TABLE A
IF
the sum of the hours worked by EMPLOYEE A on TABLE A
is not equal to N
Is this possible?
* Insert a record for EMPLOYEE A to TABLE A
IF
the sum of the hours worked by EMPLOYEE A on TABLE A
is not equal to N
Is this possible?
On 8/31/05, Michael Fuhr <mike@fuhr.org> wrote:On Wed, Aug 31, 2005 at 11:09:54AM -0400, Henry Ortega wrote:
> Is there a way to insert a record only if a certain
> condition is met?
>
> Something like:
> insert into employee values('lastname','firstname',8) where
> (condition here.. select sum(ofsomething) from xx where sum(ofsomething)>0 )
See the INSERT documentation; it mentions inserting values from a subquery.
INSERT INTO employee
SELECT 'lastname', 'firstname', 8
WHERE <condition>;
--
Michael Fuhr
В списке pgsql-sql по дате отправления: