Monday 1 May 2017

I have request data from 2 database. How can I merge code to one function?

I have request data from 2 database. But I need to merge 2 request in one function and send data to result.html

function showResult(req, res){
        var n = req.query.query
        mysql_conn.query('SELECT query_text FROM catalogsearch_query WHERE query_text LIKE "%' + n + '%" ORDER BY popularity DESC LIMIT 0 , 10', function(error, rows) {
        res.render('result.html',{result:n , related: rows.map(row => row.query_text)})
    })
}

Need to merge with this code

mysql_crawl.query('SELECT prod_name, full_price, discount_price, quantity, prod_link, images, prod_desc, status FROM `catalogsearch_fulltext` WHERE MATCH(data_index) AGAINST("cream") LIMIT 0 , 10', function(error, product_data){
res.render('result.html',{product_data: product_data})

How can I merge code together in one function?



via Moomoo Soso

No comments:

Post a Comment