Menu

I am not able to build join query

rohitagg
2004-06-18
2004-06-20
  • rohitagg

    rohitagg - 2004-06-18

    I want to build this query

    select item.id,item.name,item.price,reward.discount from item ,reward where item.itemid*=reward.itemid

     
    • Richard Banks

      Richard Banks - 2004-06-20

      Firstly, the syntax you are using is quite old.  You should be specifying joins in the from clause (unless you DB doesn't support it).

      Outer joins aren't created by the framework as all of the retrieve criteria and multiretrieve criteria work on object to object relationships, and there is an assumption that empty objects aren't persisted or retrievable.

      That said, you can do what you want using CPersistenceBroker.ProcessDirectSQL()

      Simply pass the SQL string as you have posted and the framework will convert the class and property names into tables and columns based on your mappings.  The result will be a CCursor object that you can use to access the recordset.
      Note: I am assuming that item and reward are class names not table names.

      - Richard.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.