Ashu Ashu - 13 days ago 8
SQL Question

SQL query into Hibernate query

How do I write this SQL query as a Hibernate query?

SELECT u.id, u.orderId, p.productName, u.key2, i.forsor_id
FROM `ub_orders` u JOIN
productInfo p
ON p.productId=u.productId JOIN
ir i
ON u.key2=i.id
WHERE p.productName LIKE '%OSS HOSTING FEE%' AND
u.createdDate > 2014-02-1 AND
forsor_id IS NULL
ORDER BY u.key2;

Answer

I readily see two problems. The first is the use of backticks and the second is the need for single quotes around the date constant:

 SELECT u.id, u.orderId, p.productName, u.key2, i.forced_matrix_sponsor_id
 FROM ubercart_reseller_orders u join
      productInfo p
      on p.productId=u.productId join
      ir i
      on u.key2=i.id
 where p.productName like '%OSS HOSTING FEE%' and
       u.createdDate > '2014-02-1' and
 ----------------------^
       forced_matrix_sponsor_id is null
 order by u.key2;
Comments