- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does it mean by select 1 from MySQL table?
152 Lectures 16 hours
87 Lectures 5.5 hours
The statement ‘select 1’ from any table name means that it returns only 1. For example, If any table has 4 records then it will return 1 four times.
Let us see an example. Firstly, we will create a table using the CREATE command.
mysql> create table StudentTable -> ( -> id int, -> name varchar(100) -> ); Query OK, 0 rows affected (0.51 sec)
mysql> insert into StudentTable values(1,'John'),(2,'Carol'),(3,'Smith'),(4,'Bob'); Query OK, 4 rows affected (0.21 sec) Records: 4 Duplicates: 0 Warnings: 0
To display all the records.
mysql> select *from StudentTable;
Here is the output.
+------+-------+ | id | name | +------+-------+ | 1 | John | | 2 | Carol | | 3 | Smith | | 4 | Bob | +------+-------+ 4 rows in set (0.00 sec)
The following is the query to implement "select 1".
mysql> select 1 from StudentTable;
Here is the 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.
Note: It returns 1 N times, if the table has N records.
- What does parenthesis mean in MySQL SELECT (COLNAME)?
- Select from table where value does not exist with MySQL?
- Insert values in a table by MySQL SELECT from another table in MySQL?
- What do you mean by PRIMARY KEY and how can we use it in MySQL table?
- What do you mean by FOREIGN KEY and how can we use it in MySQL table?
- "Makkal Needhi Maiam" what does it mean?
- How to select from MySQL table A that does not exist in table B?
- MySQL SELECT from table A that does not exist in table B using JOINS?
- What does INT(7) in MySQL mean?
- What does “unsigned” in MySQL mean and when to use it?
- Select records from MySQL NOW() -1 Day?
- What does the KEY keyword mean in MySQL?
- What does select @@identity do in MySQL?
- What does the slash mean in a MySQL query?
- What does these operators mean (** , ^ , %, //) ?