
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Can we set a single value in MySQL SELECT IN()?
Yes, we can set a single value with IN() in MySQL. Let us first create a table−
mysql> create table DemoTable -> ( -> FirstName varchar(20) -> ); Query OK, 0 rows affected (0.65 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.42 sec) mysql> insert into DemoTable values('David'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Mike'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Bob'); Query OK, 1 row affected (0.08 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output:
+-----------+ | FirstName | +-----------+ | Chris | | David | | Mike | | Bob | +-----------+ 4 rows in set (0.00 sec)
Following is the query to set a single value with MySQL IN −
mysql> select *from DemoTable where FirstName IN('Mike');
This will produce the following output:
+-----------+ | FirstName | +-----------+ | Mike | +-----------+ 1 row in set (0.00 sec)
- Related Articles
- Can we use SELECT NULL statement in a MySQL query?
- MySQL select only a single value from 5 similar values?
- Can we use WHERE, AND & OR in a single MySQL query?
- How to set two variables in a stored procedure with a single MySQL select statement?
- Can we implement nested insert with select in MySQL?
- How can we use SET statement to assign a SELECT result to a MySQL user variable?
- Can we implement 'LIKE' and ‘IN’ in a single MySQL query?
- Can we use a comma between MySQL SELECT statements?
- Set MySQL select in a custom variable
- MySQL UNION SELECT and IN clause in a single query
- A single MySQL query to select value from first table and insert in the second?
- Can we update a row with the highest ID in a single MySQL query?
- How can we delete a single row from a MySQL table?
- Can we select row by DATEPART() in MySQL? Is it possible?
- Can we select field name in MySQL that contains an asterisk?

Advertisements