PHP MySQL Where Yarima
- Previous Page MySQL Select
- Next Page MySQL Order By
Kuwa ni lazima kuingiza WHERE mtaala kwenye uigizo SELECT iweze kuwa kusoma data za kutokea kwa maelezo yenye maelezo yenye maelezo yenye maelezo.
WHERE mtaala
Kuwa ni lazima kuingiza WHERE mtaala kwenye uigizo SELECT iweze kuwa kusoma data za kutokea kwa maelezo yenye maelezo yenye maelezo yenye maelezo.
Mwakilishi
SELECT kolu FROM table WHERE kolu operator wakati
Kiwani na kuma za kusoma zina wakilika kwa WHERE mtaala.
Operator | Explanation |
---|---|
= | Equal |
!= | Not equal |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
BETWEEN | Between a range of containing |
LIKE | Search patterns matching |
Note:SQL statements are case-insensitive. WHERE is equivalent to where.
To make PHP execute the above statement, we must use the mysql_query() function. This function is used to send queries and commands to SQL connections.
Example
The following example will select all rows from the 'Persons' table where FirstName='Peter':
<?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM Persons WHERE FirstName='Peter'"); while($row = mysql_fetch_array($result)) { echo $row['FirstName'] . " " . $row['LastName']; echo "<br />"; } ?>
Output of the above code:
Peter Griffin
- Previous Page MySQL Select
- Next Page MySQL Order By