Hi Rainer,

I have some basic SQL questions that I am not sure how to write it using 
Empire-DB.


1.       How do I include an 'AND' statement in a left join?



This is what I would like to achieve.



SELECT t2.PO_CIRCUIT, t2.PON--, t3.ATTRIBUTE_VALUE

FROM CIRCUIT_WITH_ATTR t2

left join CIRCUIT_WITH_MULTI_ATTR t3 on t2.CIRCUIT_WITH_ATTR_ID = 
t3.CIRCUIT_WITH_ATTR_ID and t3.ATTRIBUTE_NAME='SECONDARY_CIRCUIT',

CUSTOMER_CIRCUIT_IMPACT t7

WHERE t7.ITEM_ID=74114696

  AND (t2.PON is not null OR t2.PO_CIRCUIT is not null)

  AND t7.CIRCUIT_WITH_ATTR_ID=t2.CIRCUIT_WITH_ATTR_ID;



This is what I have written using empire-db
                cmd.select(db.T_CIRCUIT_WITH_ATTR.C_PO_CIRCUIT, 
db.T_CIRCUIT_WITH_ATTR.C_PON, db.T_CIRCUIT_WITH_MULTI_ATTR.C_ATTRIBUTE_NAME);
                cmd.join(db.T_CIRCUIT_WITH_ATTR.C_CIRCUIT_WITH_ATTR_ID, 
db.T_CIRCUIT_WITH_MULTI_ATTR.C_CIRCUIT_WITH_ATTR_ID, DBJoinType.LEFT);
//                         .and(db.T_CIRCUIT_WITH_MULTI_ATTR.C_ATTRIBUTE_NAME, 
"SECONDARY_CIRCUIT"); This line gave me an error
                cmd.where(db.T_CUSTOMER_CIRCUIT_IMPACT.C_ITEM_ID.is(lItemId) );
                
cmd.where(db.T_CUSTOMER_CIRCUIT_IMPACT.C_CIRCUIT_WITH_ATTR_ID.is(db.T_CIRCUIT_WITH_ATTR.C_CIRCUIT_WITH_ATTR_ID)
 );
      Also, I am not sure how to add the 2nd 'AND' statement.


2.  How to include a function call in an 'AND' statement.



Regular SQL:

  Select customer_circuit

  From customer_impact

  Where item_id = some value

    And REGEXP_LIKE(customer_circuit, string); REGEXP_LIKE is a function call.

I would appreciate your help.




Thank You,



Chieu Nguyen
[email protected]

Reply via email to