Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
MSSQL LIKE operator with Node.js SQL query

I am trying to get data even when "naziv" query value is not an exact match with the value from the table but just a similar one.

const sqlConfig = require("../config/ms.config")

exports.data = async (req, res) => {

    const { sifart, naziv, uempl, idfirma } = req.query

    try {

            await sql.connect(sqlConfig.sqlConfig)
            var tableData = await sql.query(' SELECT sifart,naziv,uempl,idfirma FROM [dbo].[artikli] WHERE (sifart = '+ sifart +' OR '+ sifart +' IS NULL) AND (naziv LIKE '+ naziv +' OR '+ naziv +' IS NULL) AND (uempl = '+ uempl +' OR '+ uempl +' IS NULL) AND (idfirma = '+ idfirma +' OR '+ idfirma +' IS NULL) ')
            var result = JSON.parse(JSON.stringify(tableData))
            console.log(result.recordset)
            res.status(200).send(result.recordset)

        } catch (err) {
            res.status(404).send({message: "Cannot find, please try something else!"});
            console.log(err)
        }

}
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!