>could you give me an example?
>I've searched for some examples on joining tables, but couldn't get it to
>work.
>
>rg,
>Eric
Probably because you should have been looking for UNION
instead of JOIN, e.g.:
(
SELECT commonA, field1, field2,
'constA3', 'constA4', 'constA5'
FROM tableA WHERE ...
)UNION(
SELECT commonB, 'constB1', 'constB2',
field3, field4, 'constB5'
FROM tableB WHERE ...
)UNION(
SELECT commonC, 'constC1', 'constC2',
'constC3', 'constC4', field5
FROM tableC WHERE ...
);
you could use UNION ALL to preserve duplicates between
SELECTs - but I don't think that applies here.
Note that the column value's data types (or the "constant"
replacements) in each of the SELECT's column positions need
to be compatible.
>> The most efficient way, would be to do joins in your SQL query, so this is
>> all done at the database level.
[quoted text clipped - 21 lines]
>>> rg,
>>> Eric
'Any fool can write code that a computer can understand.
Good programmers write code that humans can understand.'
Martin Fowler,
'Refactoring: improving the design of existing code', p.15
Cor Ligthert - 11 Jan 2005 08:26 GMT
I hate SQL so I always try too avoid it.
However being active in these newsgroups is every time learning more of it.
Eric, when this works, will you than answer that here, this can be a great
addition.
Cor