
- 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
MySQL where column = 'x, y, z'?
You can use IN operator for this.
The syntax is as follows −
SELECT *FROM yourTableName WHERE yourColumnName IN(‘yourValue1’,‘yourValue2’,‘yourValue3’,...........N);
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table InOperatorDemo -> ( -> ClientId int -> ); Query OK, 0 rows affected (0.52 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into InOperatorDemo values(101); Query OK, 1 row affected (0.19 sec) mysql> insert into InOperatorDemo values(110); Query OK, 1 row affected (0.11 sec) mysql> insert into InOperatorDemo values(120); Query OK, 1 row affected (0.17 sec) mysql> insert into InOperatorDemo values(230); Query OK, 1 row affected (0.11 sec) mysql> insert into InOperatorDemo values(270); Query OK, 1 row affected (0.15 sec) mysql> insert into InOperatorDemo values(300); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from InOperatorDemo;
The following is The output −
+----------+ | ClientId | +----------+ | 101 | | 110 | | 120 | | 230 | | 270 | | 300 | +----------+ 6 rows in set (0.00 sec)
Here is the query to get value from column with IN operator −
mysql> select *from InOperatorDemo where ClientId IN('120','270','300');
The following is The output −
+----------+ | ClientId | +----------+ | 120 | | 270 | | 300 | +----------+ 3 rows in set (0.00 sec)
- Related Articles
- Subtract $3 x y+5 y z-7 z x$ from $5 x y-2 y z-2 z x+10 x y z$.
- Verify: $x\times(y\times z)=(x\times y)\times z$, where $x=\frac{1}{2},\ y=\frac{1}{3}$ and $z=\frac{1}{4}$.
- Subtract x²-y²+z² from x²-y²- z²
- Verify that \( x^{3}+y^{3}+z^{3}-3 x y z=\frac{1}{2}(x+y+z)\left[(x-y)^{2}+(y-z)^{2}+(z-x)^{2}\right] \)
- If \( x+y+z=0 \), show that \( x^{3}+y^{3}+z^{3}=3 x y z \).
- In \( \Delta X Y Z, X Y=X Z \). A straight line cuts \( X Z \) at \( P, Y Z \) at \( Q \) and \( X Y \) produced at \( R \). If \( Y Q=Y R \) and \( Q P=Q Z \), find the angles of \( \Delta X Y Z \).
- Factorise:(i) \( 4 x^{2}+9 y^{2}+16 z^{2}+12 x y-24 y z-16 x z \)(ii) \( 2 x^{2}+y^{2}+8 z^{2}-2 \sqrt{2} x y+4 \sqrt{2} y z-8 x z \)
- Factorise:\( 4 x^{2}+9 y^{2}+16 z^{2}+12 x y-24 y z-16 x z \)
- If \( 3^{x}=5^{y}=(75)^{z} \), show that \( z=\frac{x y}{2 x+y} \).
- Factorise : \( 27 x^{3}+y^{3}+z^{3}-9 x y z \)
- Simplify:$2 x+3 y-4 z-(3 y+5 x-2 z)$
- Add: $20 x^{2} y^{2} z and -10 x^{2} y^{2} z$
- If $x+y+z = 0$ show that $x^{3}+y^{3}+z^{3}=3xyz$
- Multiply:$x^2 +y^2 + z^2 - xy + xz + yz$ by $x + y - z$
- Verify the property \( x \times(y+z)=(x \times y)+(x \times z) \) for the given values of \( x,\ y \) and \( z \).\( x=\frac{-5}{2}, y=\frac{1}{2} \) and \( z=-\frac{10}{7} \)>

Advertisements