J. St J. St - 2 months ago 7
MySQL Question

How to return only certain rows

I have table1 in MySql like this.

----------------
|A |B |C |
----------------
|A1 |AA |01 |
|A2 |BA |01 |
|A2 |BA |02 |
----------------


I want to select column B where A is "A2" like this.

------
|B |
------
|BA |
|BA |
------


then, I want to select column C where B is "BA" and A is "A2".

------
|C |
------
|01 |
|02 |
------


can you help me? thank you.

Answer

You can query like :

SELECT B FROM table1 WHERE A='A2';

SELECT C FROM table1 WHERE B='BA' AND A='A2';
Comments