I want to make a query in C++ using the MySQL++ API.

Here is my problem, in PHP for example I make something like this:

$query = "SELECT * FROM table1 WHERE id = " . $value;

In C++ I can't do that. I need a way to make $value be part of the query string. I know it is a silly question, but can someone help me find this answer?

Thank You

you could use std::string class and just concantinate the value with the string

std::string query = "SELECT * FROM table1 WHERE id = ";
query += value;

now the problem is that if value is a string you will probably have to enclose it in quotes

std::string query = "SELECT * FROM table1 WHERE id = '";
query += value;
query += "'";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.