Subject Re: [firebird-support] Getting One Record
Author Alexandre Benson Smith
moacirponti wrote:

>Hi,
>
> An SQL problem!
>
> I have 3 tables: PROJECT, AUTHORS and KEYWORDS
>
> One Project have various AUTHORS and various KEYWORDS, this two
>tables have the fields PRCODE, with the code of their Projects.
>
> I want to do a select that retrieves:
>
> One Record containing: PROJECT CODE, PROJECT TITLE, the first
>AUTHOR.
> This search can be made on fields: AUTHOR, TITLE or KEYWORDS
>
> That is my "select":
>
> SELECT A.CODE, A.TITLE, B.NAME, C.WORD from PROJECT A, AUTHORS B,
>KEYWORDS C
> WHERE (B.NAME like %AnyString% or C.WORD like %AnyString% or
>A.TITLE like %AnyString%)
> AND B.PRCODE = A.CODE
> AND C.PRCODE = A.CODE
>
> Example of the select above.
> For a project with 2 authors and 3 keywords this is returning:
>
> 1 The-Project-Title First-Author First-Keyword
> 1 The-Project-Title Second-Author First-Keyword
> 1 The-Project-Title First-Author Second-Keyword
> 1 The-Project-Title Second-Author Second-Keyword
> 1 The-Project-Title First-Author Third-Keyword
> 1 The-Project-Title Second-Author Third-Keyword
>
>
> Why can I made a SELECT that retrieves one RECORD, containint the
>first author and first keyword only?
>
> Thanks a lot
>
> Moacir
>
>
Moacir,

SELECT first 1 A.CODE, A.TITLE, B.NAME, C.WORD from PROJECT A, AUTHORS B,
KEYWORDS C
WHERE (B.NAME like %AnyString% or C.WORD like %AnyString% or
A.TITLE like %AnyString%)
AND B.PRCODE = A.CODE
AND C.PRCODE = A.CODE


see you !

--

Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br