title: "Truncated incorrect DOUBLE value: 'undefined'" when trying to update data in CRUD
body: <p>My update function doesn't work when a trying to update some data. I receive this error</p>
  <pre><code>&quot;Truncated incorrect DOUBLE value: 'undefined'&quot;
  </code></pre>
  <p>I searched and some solutions said about the type of data being wrong, that a string value being compared with a varchar or int value, but the  values that are passed are correct, my id column in database are receiving a int value.I saw that function CAST() could be used in cases where ocurred this type of error,but I dont know if is could be used in this case,I tried but doesn't worked.</p>
  <p>This are my index.js code</p>
  <pre><code>const dotenv = require('dotenv')
  const path = require('path');
  const express = require('express')
  const app = express();
  const mysql = require('mysql2');
  const cors = require('cors')
  
  app.use(express.json());
  app.use(cors());
  dotenv.config({ path: path.join(__dirname, './.env')})
  
  const db = mysql.createPool({
      host: &quot;localhost&quot;,
      user: &quot;root&quot;,
      password: &quot;root&quot;,
      database: &quot;phonecontact&quot;,
  });
  
  
  app.post(&quot;/register&quot;, (req,res) =&gt; {
      const { name }  = req.body;
      const { phonenumber } = req.body;
      const { email } = req.body;
  
  
      let QUERY = &quot;INSERT INTO contact ( name, phonenumber, email ) VALUES ( ?, ?, ? )&quot;;
  
      db.query(QUERY, [name, phonenumber, email], (err,result) =&gt; {
          if(err) console.log(err)
          else res.send(result);
      })
  })
  
  app.get(&quot;/getCards&quot;, (req,res) =&gt; {
  
      let QUERY = &quot;SELECT * FROM contact&quot;;
  
      db.query(QUERY, (err,result) =&gt; {
        if(err) console.log(err);
        else res.send(result);
      })
  })
  
  app.post('/search', (req,res) =&gt; {
    const { name } = req.body;
    const { email } = req.body;
    const { phonenumber } = req.body;
  
    let QUERY = &quot;SELECT * FROM contact WHERE name = ? AND email = ? AND phonenumber = ?&quot;;
  
    db.query(QUERY, [name,email,phonenumber], (err,result) =&gt; {
      if(err) console.log(err)
      else res.send(result)
    })
  })
  
  app.put(&quot;/editContacts&quot;, (req,res) =&gt; {
    const { id } = req.body;
    const { name } = req.body;
    const { email } = req.body;
    const { phonenumber } = req.body;
  
    let QUERY = &quot;UPDATE contact SET name = ?, email = ?, phonenumber = ? WHERE idcontact = ?&quot;;
  
    db.query(QUERY,[name,email,phonenumber,id], (err,result) =&gt; {
      if(err) console.log(err);
      else res.send(result)
    })
  })
  
  app.delete(&quot;/delete/:id&quot;, (req,res) =&gt; {
    const { id } = req.params;
    let QUERY = &quot;DELETE FROM contact WHERE idcontact = ?&quot;;
    db.query(QUERY, id, (err,result) =&gt; {
      if(err) console.log(err)
      else res.send(result);
    })
  })
  
  
  
  app.listen(3001, () =&gt; {
      console.log('Servidor ligado na porta 3001')
  })
  </code></pre>
  <p>This is my form that I'm using to insert data. I'm using material ui dialog form</p>
  <pre><code>import React, { useState } from &quot;react&quot;;
  import Button from '@mui/material/Button';
  import TextField from '@mui/material/TextField';
  import Dialog from '@mui/material/Dialog';
  import DialogActions from '@mui/material/DialogActions';
  import DialogContent from '@mui/material/DialogContent';
  import DialogTitle from '@mui/material/DialogTitle';
  import Axios from 'axios';
  
  export default function FormDialog(props) {
  
    const [editValues, setEditValues] = useState({
      id: props.id,
      name: props.name,
      email: props.email,
      phonenumber: props.phonenumber,
    });
  
    const handleChange = value =&gt; {
      setEditValues((prevValues) =&gt; ({
        ...prevValues,
        [value.target.id]: value.target.value,
      }));
    };
  
    const handleClose = () =&gt; {
      props.setOpen(false);
    };
  
    const handleEditContacts = () =&gt; {
      Axios.put('http://localhost:3001/editContacts', {
        id: editValues.id,
        name: editValues.name,
        email: editValues.email,
        phonenumber: editValues.phonenumber,
      })
      handleClose();
    }
  
    const handleDeleteContacts = () =&gt; {
      Axios.delete(`http://localhost:3001/delete/${editValues.id}`)
      handleClose();
  
    }
  
    return (
      &lt;Dialog
        open={props.open}
        onClose={handleClose}
      &gt;
        &lt;DialogTitle&gt;Editar&lt;/DialogTitle&gt;
        &lt;DialogContent&gt;
          &lt;TextField
            autoFocus
            margin=&quot;dense&quot;
            id=&quot;name&quot;
            label=&quot;Nome&quot;
            defaultValue={props.name}
            onChange={handleChange}
            type=&quot;text&quot;
            fullWidth
          /&gt;
          &lt;TextField
            autoFocus
            margin=&quot;dense&quot;
            id=&quot;email&quot;
            label=&quot;Email&quot;
            defaultValue={props.email}
            onChange={handleChange}
            type=&quot;email&quot;
            fullWidth
          /&gt;
          &lt;TextField
            autoFocus
            margin=&quot;dense&quot;
            id=&quot;telefone&quot;
            label=&quot;Telefone&quot;
            defaultValue={props.phonenumber}
            onChange={handleChange}
            type=&quot;tel&quot;
            fullWidth
          /&gt;
        &lt;/DialogContent&gt;
        &lt;DialogActions&gt;
          &lt;Button onClick={handleClose}&gt;Cancelar&lt;/Button&gt;
          &lt;Button onClick={handleEditContacts}&gt;Salvar&lt;/Button&gt;
          &lt;Button onClick={handleDeleteContacts}&gt;Excluir&lt;/Button&gt;
        &lt;/DialogActions&gt;
      &lt;/Dialog&gt;
    );
  }
  </code></pre>
  <p>My App.js</p>
  <pre><code>import React, { useEffect, useState } from 'react';
  import './App.css';
  import Axios from 'axios';
  import Card from './Components/Card/Card';
  
  function App() {
    const [values, setValues] = useState();
    const [listCard, setListCard] = useState([]);
  
    const handleClick = () =&gt; {
      Axios.post('http://localhost:3001/register', {
        name: values.name,
        phonenumber: values.phonenumber,
        email: values.email,
      }).then(() =&gt; {
        Axios.post('http://localhost:3001/search', {
          name: values.name,
          phonenumber: values.phonenumber,
          email: values.email,
        }).then((response) =&gt; {
          setListCard([
            ...listCard,
            {
              id: response.data[0].id,
              name: values.name,
              email: values.email,
              phonenumber: values.phonenumber,
            },
          ])
        });
      })
    }
  
    useEffect(() =&gt; {
      Axios.get('http://localhost:3001/getCards').then((response) =&gt; {
        setListCard(response.data);
        })
    }, [listCard]);
  
    const handleChange = (value) =&gt; {
      setValues((prevValues) =&gt; ({
        ...prevValues,
        [value.target.name]: value.target.value,
      }));
    };
  
  
  
    return (
      &lt;div className=&quot;App&quot;&gt;
        &lt;div className=&quot;contact&quot;&gt;
          &lt;h1&gt;Cadastro de Contato&lt;/h1&gt;
          &lt;input type=&quot;text&quot; name=&quot;name&quot; placeholder=&quot;Nome&quot; className=&quot;register-input&quot; onChange={handleChange} /&gt;
          &lt;input type=&quot;tel&quot; name=&quot;phonenumber&quot; placeholder=&quot;Telefone&quot; className=&quot;register-input&quot; onChange={handleChange} /&gt;
          &lt;input type=&quot;email&quot; name=&quot;email&quot; placeholder=&quot;Email&quot; className=&quot;register-input&quot; onChange={handleChange} /&gt;
          &lt;button onClick={handleClick}&gt;Cadastrar&lt;/button&gt;
        &lt;/div&gt;
        {listCard.map((val) =&gt; (
          &lt;Card
            key={val.idcontact}
            listCard={listCard}
            setListCard={listCard}
            id={val.idcontact}
            name={val.name}
            email={val.email}
            phonenumber={val.phonenumber}
          /&gt;
  
        ))}
      &lt;/div&gt;
    );
  }
  
  export default App;
  </code></pre>
  <p>And finally my table structure</p>
  <pre><code>idcontact int AI PK 
  name varchar(100) 
  phonenumber varchar(11) 
  email varchar(100)
  </code></pre>