Subject | Re: [firebird-support] Check if record exist |
---|---|
Author | Sibo Oskam |
Post date | 2005-01-27T09:32:16Z |
Hi Helen,
I have just bought your book. It's great.
I now tried: select 1 from Person where PersId=:PersId
It also seems to work.
Sibo
I have just bought your book. It's great.
I now tried: select 1 from Person where PersId=:PersId
It also seems to work.
Sibo
----- Original Message -----
From: "Helen Borrie" <helebor@...>
To: <firebird-support@yahoogroups.com>
Sent: Thursday, January 27, 2005 10:20 AM
Subject: Re: [firebird-support] Check if record exist
>
> At 10:04 AM 27/01/2005 +0100, you wrote:
>
>>I want to check if a record exist in SQL. Of course I could use:
>>Select Count(*) From Person Where PersId=:PersId
>>and check if a what is returned is higher than 0, but if there are a lot
>>of records that will take a lot of time
>>
>>I want to something like:
>>Select First 1 Count(*) From Person Where PersId=:PersId
>>
>>Or
>>Select Count(*) From Person Where PersId=:PersId And RecordCount<2
>>
>>Both do not work. How do I do this.
>
> If you just want to check for existence and return something small:
>
> select 1 from rdb$database
> where exists (select 1 from Person where PersId=:PersId)
> returns 1 if there is at least one matching row; returns empty set
> otherwise.
>
> ./hb
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>