⊗ppPmDBSF 371 of 447 menu

Selection Fields in SQL Query in PHP

In previous lessons, when selecting from the database, all columns of the table were included in the result. This is not actually mandatory - you can specify which specific fields we need.

To do this, instead of the asterisk we put after the SELECT command, you can list the names of the required fields separated by commas.

Let's look at an example. Let's retrieve only the name and age of the employee from our users table:

<?php $query = "SELECT name, age FROM users WHERE id >= 3"; ?>

Select the name, age, and salary for each employee from the users table.

Select the names of all employees from the users table.

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