Selecting from multiple tables in queryString

2005-04-14
2013-04-25
  • I have some fields that are accessed from more than one table in my mySQL database.  I've tried using standard SELECT constructs to specify the queryString, but OR Designer always reports syntax errors (when trying to view).  None of the JasperReports samples I saw selected from more than one table.  Is this possible in OR Designer?  I *was* able to compile it, so maybe it's good to go for OpenReports ingestion(?)

    Here's a sanitized sample of one of the queryStrings I tried:

    <queryString><![CDATA[select field1, field2 from table1, table2]]></queryString>

    Thanks!

     
    • Dima-A
      Dima-A
      2005-04-14

      I'm selecting from multiple tables without any problems using mySQL.

      Look for an error in your query. Take the query you are trying to run and actually run it in the MYSQL directly. Only if it runs without problems you can start looking for other problems.

      You may need to qualify fields in your select statements with table name like this: 

      select table1.field1, table2.field2 

      or use alias:  select t1.field1, t2 field2 from table1 t1, table2 t2

      Also you don't seem to include any where clause in your statement. that may cause the problem too.

      Hope this helps.

       
    • Thanks.  This had occurred to me to first try it in mySQL directly, but since I was taking this syntax straight out of a mySQL book, I figured it should work.  I did try qualifying the fields with table names, but that didn't work either.  In any case, I'll see if I can make headway by checking the queries directly with mySQL first.