mysql1_dart icon indicating copy to clipboard operation
mysql1_dart copied to clipboard

where ... like with parameter

Open ChristophKe opened this issue 2 years ago • 1 comments

how do I write a "like" with a parameter in a query?

... where col like "%?%" with a given Parameter 'abc'

Leads to Exception (Length of parameters (1) does not match parameter count in query (0))

Christoph

ChristophKe avatar Oct 28 '22 07:10 ChristophKe

You can try this


MySqlConnection conn = await MySqlConnection.connect(...);
Results results = await conn.query("SELECT FROM table WHERE col LIKE CONCAT('%', ?, '%')", [variable]);

ArturPasetto avatar May 29 '23 14:05 ArturPasetto