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

Hi!

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.

Cheers,
Luís

Options: ReplyQuote


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


Sorry, only registered users may post in this forum.

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.