MySQL Forums
Forum List  »  Connector/C++

Re: Proper way of using expr in complicated queries
Posted by: Luis Silva
Date: May 17, 2022 08:53AM


Sorry for the late reply...

The INTERVAL isn't supported... that's why it fails when using table().where();

Solution is to use the general Session.sql();

There you can pass arguments using ? (named binds are not possible).

So your query would be:

auto sql = session.sql("SELECT * FROM table
WHERE column1 IS NULL OR (column2 is NULL AND DATE_SUB(NOW(), INTERVAL ? SECOND) > column1);");

then to execute:
auto result = sql.bind(10).execute();

Hope it hepls.


Options: ReplyQuote

Written By
Re: Proper way of using expr in complicated queries
May 17, 2022 08:53AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.