What is the problem with your ? and ?? parameters?
Opened this issue · 1 comments
suchislife801 commented
Your examples are so small...
I have no idea how to execute an UPDATE query with a WHERE clause. It keeps thinking field values are field names. No documentation anywhere to learn from. Just 5 little dinky examples on your main page for people who are not really serious. You help section is soooo lacking...
WHY DOESN'T THIS WORK?
const sqlUpdateCompany: string =
`UPDATE tblCompanies
SET
startDate = ?,
name = ?,
owner = ?,
status = ?,
ein = ?,
taxForm = ?,
industry = ?,
stateLicenseNumber = ?,
address1 = ?,
city = ?,
state = ?,
postalCode = ?,
email = ?,
phone = ?,
url = ?,
notes = ?
WHERE
id = ?`;
// EXECUTE QUERY
const sqlUpdateCompanyResult = await MYSQL_CONN.execute(sqlUpdateCompany, [
reqBody.params.startDate,
reqBody.params.name,
reqBody.params.owner,
reqBody.params.status,
reqBody.params.ein,
reqBody.params.taxForm,
reqBody.params.industry,
reqBody.params.stateLicenseNumber,
reqBody.params.address1,
reqBody.params.city,
reqBody.params.state,
reqBody.params.postalCode,
reqBody.params.email,
reqBody.params.phone,
reqBody.params.url,
reqBody.params.notes,
reqBody.params.id
]);
Error: Unknown column '2023-01-01' in 'field list'
Why does it think the the value of startDate
is the field name in the database?
lideming commented
Seems to be the ANSI_QUOTES mode (MySQL docs: https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_ansi_quotes).
Currently the sql-builder module uses double quotes "
for string values. (issue: manyuanrong/sql-builder#15)