⊗ppSpPDLW 68 of 83 menu

Working with the LIKE Operator in PDO in PHP

To use the LIKE operator in a prepared query, you need to specify the value for its variable using a special syntax:

<?php $var = '%value%'; ?>

Let's find a user by name, using the LIKE operator:

<?php $name = '%user1%'; $res = $pdo->prepare('SELECT * FROM users WHERE name LIKE ?'); $res->execute([$name]); $row = $res->fetchAll(); var_dump($row); ?>

Display all users from the users table, whose salary is equal to 500.

Display users whose salary is equal to or more than 900, and whose age is less than 35 years.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline