select 1 in sql code example

Example: SELECT 1 from table

select * from StudentTable;

-- output : 
+------+-------+
| id   | name  |
+------+-------+
|    1 | John  |
|    2 | Carol |
|    3 | Smith |
|    4 | Bob   |
+------+-------+
4 rows in set (0.00 sec)

-- EXAMPLE OF SELECT 1 
select 1 from StudentTable;

-- output :
+---+
| 1 |
+---+
| 1 |
| 1 |
| 1 |
| 1 |
+---+
4 rows in set (0.00 sec)

-- The above returns 1 four times for 4 records, 
-- and if we had 5 records then the above query 
-- would have returned 1 five times.

Tags:

Sql Example