Sergii Rechmp
Sergii Rechmp

Reputation: 309

MySQL: How to search from two fields?

I have a table called optima with a few fields and I need to make a query that will return me results where field1 = a and field2 = b.

Table for example

F1 F2
_____
a  z
v  a
a  b
b  a

result must be:

a  b

I was trying to make query like

SELECT * FROM `optima` WHERE `F1` LIKE 'a' AND `F2` LIKE 'b';

but it returns me nothing.

Upvotes: 0

Views: 59

Answers (1)

D'Arcy Rittich
D'Arcy Rittich

Reputation: 171371

For an exact match, use the = operator, e.g.:

select *
from `optima`
where `F1` = 'a' and `F2` = 'b';

Upvotes: 2

Related Questions