# Query to extract data from MariaDB using SELECT statement to link with the RFID card detected

**URL:** https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497
**Category:** General
**Created:** [9 October 2019 09:07 UTC](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497 "2019-10-09T09:07:31Z")
**Posts on this page:** 11
**Page:** 3

<div class="post-metadata">

### Author: ![primat11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/primat11/32/12185_2.png) [@primat11](https://discourse.nodered.org/u/primat11)
#### Post date: [10 October 2019 10:29 UTC](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497/42 "2019-10-10T10:29:17Z")

</div>

Thanks @kuema for your detailed explanation. I have tried exactly like you suggested and have shared my below findings of the three debug nodes from the flow that I have.

Please see to it, the data from the database is still not getting extracted. You might get a clear view from the screenshots.

 ![IMG_20191010_122408](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/b12400bf659cb6d3e9897cbcfb6c4d5d275235bc.jpeg) ![IMG_20191010_122441](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/403dec74544bbab9dd0466cf062cd9bc414600be.jpeg) ![IMG_20191010_122420](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/36ffacc6b12d0fa8fddaadee22bb8c799db9d5cd.jpeg)

---

<div class="post-metadata">

### Author: ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)
#### Post date: [10 October 2019 10:30 UTC](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497/43 "2019-10-10T10:30:53Z")

</div>

Your function node has two outputs, please use only one directly linked to the database node and try again 😉

(I mean, you have to actually set the number of outputs to 1 again. Using multiple outputs is not needed here)

---

<div class="post-metadata">

### Author: ![primat11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/primat11/32/12185_2.png) [@primat11](https://discourse.nodered.org/u/primat11)
#### Post date: [10 October 2019 10:37 UTC](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497/44 "2019-10-10T10:37:17Z")

</div>

Thanks a lot, I just did that and now the problem is solved. Grateful to you and everyone who has helped in this matter. 🙂

---

<div class="post-metadata">

### Author: ![primat11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/primat11/32/12185_2.png) [@primat11](https://discourse.nodered.org/u/primat11)
#### Post date: [10 October 2019 10:39 UTC](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497/45 "2019-10-10T10:39:08Z")

</div>

Just one last question : Has it got anything with Primary key in the database to do? Is it necessary that the column name in the query must be a primary key in the database?

---

<div class="post-metadata">

### Author: ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)
#### Post date: [10 October 2019 10:42 UTC](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497/46 "2019-10-10T10:42:36Z")

</div>

No, not for functionality. But for performance reasons I would use proper indexes on columns that are part of conditions in your queries.

In most database systems the primary key is indexed by default, so adding one on `uID` would be a good idea. (I don't know enough about your table structure for a precise answer)

At least an index on `uID` would be recommended.

---

<div class="post-metadata">

### Author: ![primat11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/primat11/32/12185_2.png) [@primat11](https://discourse.nodered.org/u/primat11)
#### Post date: [10 October 2019 10:51 UTC](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497/47 "2019-10-10T10:51:59Z")

</div>

I changed the column uID to primary key before trying any further implementations as I thought it could also be the reason.

Thanks for your guidance and sharing knowledge. Have a nice day 🙂

Regards

---

<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: [10 October 2019 16:11 UTC](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497/48 "2019-10-10T16:11:35Z")

</div>

Just to clear up why this did not replace ${msg.payload} with the value from the payload. It is because, as I said in my last post and as detailed in the link I posted you need to use backticks not double quotes to use this form of string interpollation.

---

<div class="post-metadata">

### Author: ![primat11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/primat11/32/12185_2.png) [@primat11](https://discourse.nodered.org/u/primat11)
#### Post date: [11 October 2019 08:08 UTC](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497/49 "2019-10-11T08:08:27Z")

</div>

@Colin Thanks again for your reply. I understand exactly now what you mean, I am sorry that I somehow could not try exactly like you suggested as being a beginner I got a bit confused. I am sure it is gonna work too. Thanks for your efforts, means a lot 🙂

---

<div class="post-metadata">

### Author: ![shipra](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shipra](https://discourse.nodered.org/u/shipra)
#### Post date: [16 July 2020 07:36 UTC](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497/50 "2020-07-16T07:36:19Z")

</div>

how you have connected your database (mssql) with node red please tell

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [16 July 2020 08:51 UTC](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497/51 "2020-07-16T08:51:29Z")

</div>

@shipra - this is a thread that is 9 months old and about MariaDB not mssqj. Please stick to your original thread.

I am closing this thread.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [16 July 2020 08:51 UTC](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497/52 "2020-07-16T08:51:34Z")

</div>



[Previous page](https://discourse.nodered.org/t/query-to-extract-data-from-mariadb-using-select-statement-to-link-with-the-rfid-card-detected/16497.md?page=2)
