Jump to content

MySQL "AND" Operator


Bricktop

Recommended Posts

Hi Guys,

 

Is it possible to have two operators in one Query?  For example:

 

SELECT * FROM table WHERE username=$username AND password=$password AND answer=$answer

 

I have tried the above and it doesn't work - where am I going wrong please?  How do I write the above so it will work?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/95375-mysql-and-operator/
Share on other sites

Yes its possible, you mistake however is tat strings need to be surrounded in quotes.

 

SELECT * FROM table WHERE username='$username' AND password='$password' AND answer='$answer'

 

passowrd will also required backticks I believe because it is the name of a mysql function....

 

SELECT * FROM table WHERE username='$username' AND `password`='$password' AND answer='$answer'

Link to comment
https://forums.phpfreaks.com/topic/95375-mysql-and-operator/#findComment-488435
Share on other sites

That would require him to change his fieldname.  And why would you change the Case?

 

Try:

 

SELECT * FROM table WHERE userName = '$username' AND userPassword = '$password'" AND answer = '$answer'";

 

My bad, should have been:

 

SELECT * FROM table WHERE userName = '$username' AND Password = '$password'" AND answer = '$answer'";

Link to comment
https://forums.phpfreaks.com/topic/95375-mysql-and-operator/#findComment-488453
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.