Re: Help
Posted in 1997
Topics: SQL Development & Query Writing
paik wrote:
>
> Hello,
> I am new to SQL and I could use some help..... !!!
>
> 1) how would I implement a query so that you only result with first 4
> tuples of results?
>
> 2) I have two tables:
> ------------- ---------------
> | id | name | | id | content|
> --------------- -----------------
> | 1 a | |3 | k |
> | 2 b |4 | j |
> | 3 c | |5 | z |
> ---------------- ------------------
>
> I want the result table to contain
>
> --------------
> | 1 | | I want to list all the column of id from
> | 2 | | first field, and if there is a matching then
> | 3 | k | write that value, if not then leave it blank.
> ---------------
> get I get some tip??? ( I am using Illustra by the way)
>
> thnx
I'm not sure what you mean by "first 4 tuples of results" but to produce
the result that you illustrated, use an outer join. For example, if the
table with the "name" column is tab_1 and the table with the "content"
column is tab_2, then the following SQL statement should produce your
desired results.
select tab_1.id,content
from tab_1,outer tab_2
where tab_1.id=tab_2.id
into temp tab_3;
Of course, this assumes that the result table that you desire is a
temporary table. Good luck!
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x