Find two different Cells in one query

  • Hi

    Now I am going to test you (I hope :)). I have a system that save different kind of information in the same table. This is not normally a problem, however I need to connect two of these types of information in the same query, and I don't know have to do that.

    To explain my problem a little better I vil give an example.

    Table1

    er_id, er_entity, er_target_name, er_target_id

    1, 1,'Information1', 2000

    2, 2,'Information1', 2000

    3, 3,'Information1', 2001

    4, 4,'Information2', 2002

    5, 2000,'Information2', 2003

    So what I need is a query that can find the following results:

    1,1,'Information1', 2000,5,2000,'Information2', 2003

    2,2,'Information1', 2000,5,2000,'Information2', 2003

    My suggestion is as follows:

    SELECT A.*,B.*

    FROM entitydata_reference AS A, entity, entitydata_integer, entitydata_date

    WHERE A.er_target_id = entity_id AND A.er_entity = ei_entity AND A.er_entity = ed_entity AND

    ed_class_attribute = 914 AND A.er_class_attribute = 974 AND A.er_target_name like '000436: Jeg har et problem' AND

    EXISTS

    (

    SELECT B.er_entity, B.er_target_name,b.er_target_id

    FROM entitydata_reference AS B

    WHERE B.er_class_attribute = 895 AND B.er_entity = 5538 AND B.er_entity = A.er_target_id

    )

    And this does not work because the outer query does not know the results of the inner query.

    I hope that somebody can tell my how I can get this to work :).

    Kind regards:

    BDH

  • Do this:...

    select * from Table1 a, Table1 b

    where a.er_entity = b.er_target_id

    That should give you the results you are looking for.

  • It worked. Thanks

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply