PHP MySQL Where

The WHERE clause is used to filter records, which is to query the data under our specified conditions


Syntax

Let us use the following example:

Example

The following example will select all FirstNames from the "MyGuests" table ='Mary' row:

"; } ?>

Program execution result:

4.png


Use where condition to query all the data of FirstName='Mary' come out.

We now use phpadmin to add an Age field to the MyGuests table

The data in the table now looks like this:

14.png

Example

We now use the where clause to query those with Age less than 25:

"; } ?>

Program running results:

1.png

You can also use the following conditions

Basic syntax select field from table where where condition; Example select * from money where age = 29; Example description Query all results with age 29 in the MyGuests table
## Type Detailed explanation
## > is greater than < Less than ## >= <=
Symbol Description
Greater than or equal to
Less than or equal to
## != Not equal to ! = Equal to

Logical operators

## or Or and And Let’s take a look at an example of multiple conditions:
## Symbol Description

Example

We query the data of 'firstname'='Julie' and Age=24

"; } ?>

Program running results:

Continuing Learning
||
"; } ?>
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!