Ch3vster
Ch3vster

Reputation: 13

How to do an equality comparison in a MySQL WHERE clause?

I have this piece of code

$player = mysql_query("SELECT * FROM `Player` WHERE `LogOn` ? `GAME`")
or die(mysql_error());

My issue is where I placed question mark, I need to have it so it would be Login is equal to GAME. I probably would of found the answer by searching the web, but I lack the English words.

Upvotes: 1

Views: 51

Answers (2)

Darshan Mehta
Darshan Mehta

Reputation: 30839

Here's what you need:

SELECT * FROM `Player` WHERE `LogOn` = 'GAME'

You can use upper() for case insensitive check:

SELECT * FROM `Player` WHERE upper(LogOn) = 'GAME'

Upvotes: 1

bolav
bolav

Reputation: 6998

Use = to check for string equality.

SELECT * FROM `Player` WHERE `LogOn` = 'GAME'

Please note ' for string quotes in mysql.

Upvotes: 0

Related Questions