# Add ' character to where clause

**URL:** <https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989>\
**Category:** Ignition\
**Created:** [September 25, 2025, 7:38pm UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989 "2025-09-25T19:38:14Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![dis](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dis](https://forum.inductiveautomation.com/u/dis)\
**Post date:** [September 25, 2025, 7:38pm UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/1 "2025-09-25T19:38:14Z")

</div>

For some reason I can’t figure out how to enclose a tag with ‘ ‘ for the where clause in a BLOCK transaction.

I can put Code= ‘0001C’ and that works

but I can’t figure out what combination will do

Where the value of the tag {tag} = ‘0001C’

```python
Code=‘{tag}’ 
Code={tag}

```

incorrect syntax near ‘C’

I’ve tried:

```python
Code= “‘“ + {tag} + “‘“
Code= ‘‘‘‘ + {tag} + ‘‘‘‘
Code= concat(“‘“, {tag}, “‘“)
Code= concat(str(‘), {tag}, str(‘))
Code= concat(char(39), {tag}, char(39))

```

edited for code enclosures and prior test scenarios

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 25, 2025, 7:40pm UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/2 "2025-09-25T19:40:11Z")

</div>

`Code = {tag}`

The SQL engine will recognise it as a string.

Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![dis](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dis](https://forum.inductiveautomation.com/u/dis)\
**Post date:** [September 26, 2025, 11:04am UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/4 "2025-09-26T11:04:34Z")

</div>

That was the first thing a I tried. I see I didn’t include that in the original post.

`Code = {tag}`

and got the error

```python
Error during group execution. com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'C'. Incorrect syntax near 'C'.

```

So it appears the tag is not being sent as a string.

If I set the value ot {tag} to the literal string ‘0001C’ then

```python
Code={tag}

```

works

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 26, 2025, 11:06am UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/5 "2025-09-26T11:06:51Z")

</div>

Show us your whole query. Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![dis](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dis](https://forum.inductiveautomation.com/u/dis)\
**Post date:** [September 26, 2025, 11:13am UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/6 "2025-09-26T11:13:48Z")

</div>

There is no query, per se. This is in the Where portion of the Table action for a block item transaction. I don’t see a way to view the actual query.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/6/0664014e44ede69abf7a5b5b9c95bb9394d766f9.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 26, 2025, 11:52am UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/7 "2025-09-26T11:52:32Z")

</div>

Sorry, I've never used the Block Group so I don't think I can help further. There is a section in the docs and there's an IU video. [Block Group | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/sql-bridge-transaction-groups/transaction-group-examples/block-group#db-to-opc-mode-with-custom-where-clause).

---

<div class="post-metadata">

**Author:** ![dis](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dis](https://forum.inductiveautomation.com/u/dis)\
**Post date:** [September 26, 2025, 11:55am UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/8 "2025-09-26T11:55:36Z")

</div>

Understandable. The videos and manual don’t get this deep into the specifics. Typically one of the “cheat codes” above works.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [September 26, 2025, 12:58pm UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/9 "2025-09-26T12:58:48Z")

</div>

This looks like a bug in the parsing logic.

As a workaround, can you try adding that tag as a run always expression and set it as a string?

Then use that in the WHERE clause?

---

<div class="post-metadata">

**Author:** ![dis](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dis](https://forum.inductiveautomation.com/u/dis)\
**Post date:** [September 26, 2025, 1:58pm UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/10 "2025-09-26T13:58:06Z")

</div>

Great idea. That didn’t work but I can add an expresssion item tag and use.

`concat("'",{[default]tag},"'")`

Then the where clause is

```python
CODE={[~]Expression Item}

```

that’s a valid workaround. Thanks

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [September 26, 2025, 2:51pm UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/11 "2025-09-26T14:51:59Z")

</div>

If I was you, I would still open a ticket with support so they can investigate and fix if it turns out to be a real bug.

---

<div class="post-metadata">

**Author:** ![Clancy\_Cavanaugh](https://avatars.discourse-cdn.com/v4/letter/c/45deac/32.png) [@Clancy\_Cavanaugh](https://forum.inductiveautomation.com/u/Clancy_Cavanaugh)\
**Post date:** [September 26, 2025, 4:15pm UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/12 "2025-09-26T16:15:03Z")

</div>

Does it work if you use an expression tag without the concat with the apostrophes in the where clause?

`CODE='{[~]Expression Item}'`

What version of Ignition are you running? I’ve definitely done this before in standard transaction groups.  
I’m curious if the issue is specific to one of the following:

1. Referencing a tag from outside the group
2. Block transaction groups specifically
3. The version of Ignition

---

<div class="post-metadata">

**Author:** ![dis](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dis](https://forum.inductiveautomation.com/u/dis)\
**Post date:** [September 26, 2025, 5:39pm UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/13 "2025-09-26T17:39:33Z")

</div>

Funny you should mention that. I did submit a ticket.

---

<div class="post-metadata">

**Author:** ![dis](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@dis](https://forum.inductiveautomation.com/u/dis)\
**Post date:** [September 26, 2025, 5:41pm UTC](https://forum.inductiveautomation.com/t/add-character-to-where-clause/110989/14 "2025-09-26T17:41:11Z")

</div>

Interestingly, that does work.

Using version 8.3.0
