Jump to content


[MySQL] How to include a conditional in my MySQL query?

  • This topic is locked This topic is locked
No replies to this topic

#1 Cryo Kinesis

Cryo Kinesis

    Haphost Staff

  • Moderators
  • 128 posts
  • LocationGridania, Eorzea

Posted 05 August 2014 - 04:35 PM

Hi there,


You will usually need to apply some logic to the query that you apply to a table, and this is easily done with the WHERE keyword.

This will be followed by a fieldname, or list of them, and then the condition you want to be met.

Thus if you want to select only rows from a table WHERE the user is called Quentin you would do the follow:

$peeps = mysql_query("SELECT * FROM users WHERE firstname = 'Quentin'");


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users