-1

Here is my SQL code for a search box (table contains rankings for M and F) and I want to get data only for M:

"SELECT *
   FROM players WHERE gender = 'M' AND
   name LIKE '%{$keywords}%'
   OR surname LIKE '%{$keywords}%'
 ";

I try to get values for players who are Men (M)

So it's important that Gender was M but for second and third WHERE clause I want to put OR

Palindromer
  • 854
  • 1
  • 10
  • 29
Nikita Ribakovs
  • 305
  • 3
  • 11
  • You do not do the work for others here, but you help people by checking their code for mistakes or by helping people get started. I'll give you a generic example of a MYsqli to help you. – Jose Marques Apr 09 '17 at 11:09

1 Answers1

1

do you want something like this?

"SELECT *
   FROM players WHERE gender = 'M' AND
   ( name LIKE '%{$keywords}%'
   OR surname LIKE '%{$keywords}%')
 ";
Nidhi257
  • 754
  • 1
  • 5
  • 23