# MariaDB system.db.runPrepQuery/runPrepUpdate syntax errors

**URL:** <https://forum.inductiveautomation.com/t/mariadb-system-db-runprepquery-runprepupdate-syntax-errors/92613>\
**Category:** General Discussion\
**Tags:** scripting\
**Created:** [July 1, 2024, 11:30am UTC](https://forum.inductiveautomation.com/t/mariadb-system-db-runprepquery-runprepupdate-syntax-errors/92613 "2024-07-01T11:30:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MG3](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mg3/32/84125_2.png) [@MG3](https://forum.inductiveautomation.com/u/MG3)\
**Post date:** [July 1, 2024, 11:30am UTC](https://forum.inductiveautomation.com/t/mariadb-system-db-runprepquery-runprepupdate-syntax-errors/92613/1 "2024-07-01T11:30:40Z")

</div>

Hi All,

I hope someone can offer some advice as to what I am doing wrong in some scripting.

Before I go on, please note that numbers denoted "_v_" are variables, "_ph_" are placeholders in the `"".format()` method and "_c_" represents db columns as usual. And this script is being used to take input from a text field and filter the rows, more or less just a search utility.

To begin with I tried:

```python
system.db.runPrepQuery("SELECT `c1` FROM table WHERE `c1` LIKE %?%", [v1])

```

but this method returned a SQL Syntax error. The only work around I have found is using:

```python
v2= "%{ph1}%".format(ph1=v1)

system.db.runPrepQuery("SELECT `c1` FROM table WHERE `c1` LIKE ?", [v2])

```

if anyone can offer any advice to why the top line produced a SQL Syntax Error and the bottom did not please let me know.

Thanks all in advanced for your help.

MG.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 1, 2024, 11:40am UTC](https://forum.inductiveautomation.com/t/mariadb-system-db-runprepquery-runprepupdate-syntax-errors/92613/2 "2024-07-01T11:40:38Z")

</div>

> [@MG3](#):
>
> ` LIKE %?%`

Parameterization includes quotes for values that needs quotes. (Not really, under the hood, but that is the effect.) So the above became  
`LIKE %'something'%` when assembled.

If you don't want to assemble the percent signs into the parameter, your SQL needs to properly assemble the string, something like this:

```python
LIKE CONCAT('%', ?, '%')

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 1, 2024, 11:43am UTC](https://forum.inductiveautomation.com/t/mariadb-system-db-runprepquery-runprepupdate-syntax-errors/92613/3 "2024-07-01T11:43:56Z")

</div>

Side note: You should avoid using the back-tick punctuation for MariaDB identifiers. It supports the SQL standard (double quote marks) for identifiers, making your SQL portable to other brands. (Same with MS SQL Server: it can use standard double quotes instead of square brackets.)
