How do you define variable value that includes new line?
const statement = "SELECT *
FROM `users` u;";
It shows error newline in string
.
How do you define variable value that includes new line?
const statement = "SELECT *
FROM `users` u;";
It shows error newline in string
.
You would normally use a raw string literal like this
const s = `first line
second line`
However, this is not possible in your case since the string itself contains backticks. In this case I would use +
to connect the lines:
const statement = "SELECT *" +
" FROM `users` u;";
The string value in this example does not contain a newline (but that's ok for SQL). If you really want a newline in the string, use the escape sequence \n
.
const s = "first line\nsecond line"