Subject Re: Using unions
Author rajsubramani
Firstly, thanks in particular to Helen Borrie and Thomas Miller. Both
your replies have been very very useful indeed (though it did take me
a few minutes to figure out how to input the UDF's into the db - I
though it would be available from the server side, doh!)

select
b1.book_id,
CAST(0 AS DOUBLE PRECISION) as stock_id,
b1.price,
string2blob('') as condition from Book b1
UNION
select
bk.book_id,
sk.stock_id,
sk.price,
sk.condition
from Book bk
join Stock sk on bk.book_id = sk.book_id


Anyway, the join now works quite well.

I just wanted to ask one final question that would put the icing on
this cake (I can't get it to work and I'm not sure if it can be done).

I wish the resultant result set to be grouped by the book_id. Putting
in "group by b1.book_id" or "group by bk.book_id" does not seem to
work. I even changed the alias in the first select statement from b1
to bk.

Obviously this needs a more intelligence than I can muster.

Your help is much appreciated.

Cheers
-raj