0

Problem:

I have created a table in SQL using phpmyadmin. It has four field user_id, username, password,usertype. Then I inserted data to that table. But when I run a SQL query to get a user like this SELECT * FROM users WHERE username = tharinduS.But this works only when I use user_id = 1 instead of username = tharinduS. But username tharinduS exists in the table. I tried a lot to figure it out what's wrong with this. But I was unable to do so. Can you please someone help me to figure this out?. Thank you.

dwp
  • 908
  • 4
  • 24
  • 42
  • A string value like `tharinduS` needs to be enclosed in single quotes i.e. `SELECT * FROM users WHERE username = 'tharinduS'` – Nick May 27 '19 at 07:57
  • @Nick I do this with nodejs. so can you help me it with this command. `sql.query( 'SELECT * FROM users WHERE username = '+username,callback )` – dwp May 27 '19 at 08:09
  • `sql.query( 'SELECT * FROM users WHERE username = \''+username + '\'',callback )` – Nick May 27 '19 at 08:10

0 Answers0