# How to check user input text is not in already in SQL results

**URL:** <https://discourse.nodered.org/t/how-to-check-user-input-text-is-not-in-already-in-sql-results/59850>\
**Category:** General\
**Created:** [14 March 2022 15:36 UTC](https://discourse.nodered.org/t/how-to-check-user-input-text-is-not-in-already-in-sql-results/59850 "2022-03-14T15:36:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [14 March 2022 15:36 UTC](https://discourse.nodered.org/t/how-to-check-user-input-text-is-not-in-already-in-sql-results/59850/1 "2022-03-14T15:36:58Z")

</div>

Hello Forum,

Could you suggest me some post or link where I can see how to make a comparison between an input text and the result of a query made to an SQL table?  
The result of the query is a column extracted from an SQL Table in which each raw corrispond to a string to which my input text needs to be compared. If the new inserted text input (CODIFICA) is equal to one of the already existing I need to give a message and ask to choose another input text.

See example:

| QUERY RESULT | | | VALID INPUT TEXT | | NOT VALID INPUT TEXT |
| --- | --- | --- | --- | --- | --- |
| AAA | | | FFF | | CCC |
| BBB | | | | | |
| CCC | | | | | |
| BGA1 | | | | | |
| BGA2 | | | | | |

When a NOT valid input text is inserted, an alert message must be displayed.

In the above flow there is the check if the input text is empty, I need to add the described other check.

Thank a lot

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 March 2022 15:49 UTC](https://discourse.nodered.org/t/how-to-check-user-input-text-is-not-in-already-in-sql-results/59850/2 "2022-03-14T15:49:53Z")

</div>

You would be better to do that in the sql query by using a WHERE clause to fetch any records where the column value is equal to the value to be tested. Then if it returns nothing you you know it does not already exist.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 May 2022 15:50 UTC](https://discourse.nodered.org/t/how-to-check-user-input-text-is-not-in-already-in-sql-results/59850/3 "2022-05-13T15:50:52Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
