SELECT SPACE (15)
We can add one start and end string to display the space between them
SELECT '#', SPACE( 15 ) , '#'
Output is here
# #
We can use SPACE with our student table
SELECT name , SPACE(10), class , mark, sex FROM `student`
| name | SPACE(10) | class | mark | sex |
|---|---|---|---|---|
| John Deo | Four | 75 | female | |
| Max Ruin | Three | 85 | male | |
| Arnold | Three | 100 | male | |
| Krish Star | Four | 60 | female | |
| John Mike | Four | 60 | female | |
| Alex John | Four | 55 | male |
UPDATE student set name=CONCAT(space(5),name)
We added space before all names in our student table.
MySQLi database connection string
require "config.php";// Database connection
$query="SELECT name , SPACE(10), class FROM `student`";
if ($result_set = $connection->query($query)) {
while($row = $result_set->fetch_array(MYSQLI_ASSOC)){
echo $row['name'],$row['SPACE(10)'],$row['class']."<br>";
}
$result_set->close();
}
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.