# MySQL node, how to capitalize (only) the first letter of value when inserting?

**URL:** https://discourse.nodered.org/t/mysql-node-how-to-capitalize-only-the-first-letter-of-value-when-inserting/73942
**Category:** General
**Created:** [20 January 2023 07:54 UTC](https://discourse.nodered.org/t/mysql-node-how-to-capitalize-only-the-first-letter-of-value-when-inserting/73942 "2023-01-20T07:54:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![network\_potato](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@network\_potato](https://discourse.nodered.org/u/network_potato)
#### Post date: [20 January 2023 07:54 UTC](https://discourse.nodered.org/t/mysql-node-how-to-capitalize-only-the-first-letter-of-value-when-inserting/73942/1 "2023-01-20T07:54:41Z")

</div>

I am using `node-red-node-mysql` to insert a row into a table in a database.

The function looks like this and works perfectly:

```auto
msg.payload = [msg.customerNumber, msg.orderNumber, msg.orderDate, msg.firstName]

msg.topic = "INSERT INTO orderTable(customerNumber, orderNumber, orderDate, firstName) VALUES(?, ?, ?, ?);"

return msg;

```

What I want to do is to format `firstName` before inserting it into the table.

If `msg.firstName`'s value is `martin` I want to insert `Martin`.

If the value is `mARTIn` I also want to insert `Martin`.

How can I use UCASE/LCASE functions inside this function?

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [20 January 2023 08:59 UTC](https://discourse.nodered.org/t/mysql-node-how-to-capitalize-only-the-first-letter-of-value-when-inserting/73942/2 "2023-01-20T08:59:20Z")

</div>

Well I find this works

```auto
msg.topic = "INSERT INTO test (description) VALUES(CONCAT(UCASE(LEFT('" + msg.payload + "', 1)), LCASE(SUBSTRING('" + msg.payload + "', 2))))"
return msg;

```

Edit: This works too

```auto
msg.topic = "INSERT INTO test (description) VALUES( CONCAT(UCASE(LEFT( ? , 1)), LCASE(SUBSTRING( ? , 2))) )"
msg.payload = [msg.payload, msg.payload]
return msg;

```

---

<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: [21 March 2023 08:59 UTC](https://discourse.nodered.org/t/mysql-node-how-to-capitalize-only-the-first-letter-of-value-when-inserting/73942/3 "2023-03-21T08:59:51Z")

</div>

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