forum

home / developersection / forums / select by pair of fields in mysql

Select by pair of fields in MySQL

Anonymous User 2358 18-May-2013
Hi Expert!

I have the following table:

+-------+-------+-------------+
|column1 |column2| column3   |

|   2   |   4        |    row 1    |   < compare with this
|   4   |   3         |    row 2    | + < here`s 4
|   5   |   2        |    row 3    | + < here`s 2
|   1   |  NULL |    row 4    | - < no 4 or 2
|   5   |   6        |    row 5    | - < no 4 or 2
|  NULL |   2        |    row 6    | + < here`s 2

The problem is how to find all rows, that contain at least one searched value. For example I need to find rows like first, so I`m looking for rows with 2 or 4 in 

first two columns. So my output should be rows 2,3 and 6. I do not need to find NULL values.

Please advise.
Thanks in advance!

Updated on 18-May-2013

I am a content writter !


Message
Can you answer this question?

Answer

1 Answers

Liked By