Creating a report from 3 tables
Posted in 2000
Topics: Server Administration, Triggers, Constraints & Referential Integrity
I am an Oracle DBA who's been put in charge of a Informix database (all databases are alike right?) Anyway I have to immediately generate a report that takes columns from 3 different tables. From Table A we need user and code (it has a 3rd column FK question_id) these need to be selected where the completed column is not null From Table B we need question_id and text where question_id matches the question_id of the not null completeds returned above Table 3 answer_text (where question_id matches question_id above) I've written this and run it on an Oracle database, I've pulled it into a temporary table and pulled the report from there and also created an on update trigger that populates a holding table. But nothing I do in Informix seems to work, I can't even get past syntax errors, could someone please point me in the right direction? Thank Lizzy Sent via Deja.com http://www.deja.com/ Before you buy.
Using older SQL syntax:
SELECT a.user, a.code, b.question_id, b.text, c.answer_text
FROM table_a a, table_b b, table_c c
WHERE a.question_id = b.question_id
AND a.question_id = c.question_id
AND a.completed IS NOT NULL;
Or using SQL-92 syntax (if you have 7.3x+):
SELECT a.user, a.code, b.question_id, b.text, c.answer_text
FROM table_a a JOIN table_b b, table_c c
ON a.question_id = b.question_id
AND a.question_id = c.question_id
WHERE
AND a.completed IS NOT NULL;
(I think don't use SQL-92 much).
What's so hard or did you not tell us something?
Art S. Kagel
elizabeth1000@my-deja.com wrote:
>
> I am an Oracle DBA who's been put in charge of a Informix database (all
> databases are alike right?) Anyway I have to immediately generate a
> report that takes columns from 3 different tables.
>
> From Table A we need user and code (it has a 3rd column FK question_id)
> these need to be selected where the completed column is not null
>
> From Table B we need question_id and text where question_id matches the
> question_id of the not null completeds returned above
>
> Table 3 answer_text (where question_id matches question_id above)
>
> I've written this and run it on an Oracle database, I've pulled it into
> a temporary table and pulled the report from there and also created an
> on update trigger that populates a holding table. But nothing I do in
> Informix seems to work, I can't even get past syntax errors, could
> someone please point me in the right direction?
>
> Thank
>
> Lizzy
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.