PL/SQL (MOSC)

MOSC Banner

Table join - merging 2 tables

edited Feb 2, 2011 2:14AM in PL/SQL (MOSC) 8 commentsAnswered
I have 2 big tables.

Table 1 has item_id, trans_date, trans_qty, etc.

Table 2 has item_id, trans_date, trans_qty, etc.

The problem I have is that I am trying to get the first 10 transaction from both tables.

What I do is

select item_id, trans_date,trans_qty,'T1' from table_1 where item_id = 111

union all

select item_id, trans_date,trans_qty,'T2' from table_2 where item_id = 111

order item_id, trans_date;

The problem with is that I am trying to get only the first 10 rows.

But when I look at the explain plain it retreive all data from  Table_1 and Table_2 which is long.

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center