1

I'm Trying to search for usernames using LIKE query, however the query always return 0 and the usernames does exists! I'm using MYSQL terminal that with MAMP PRO server and here what i tried:

SELECT * FROM userlogin WHERE username LIKE '٪w٪';
SELECT * FROM userlogin WHERE username LIKE '٪w';
SELECT * FROM userlogin WHERE username LIKE 'w٪';
SELECT * FROM userlogin WHERE username LIKE '٪?٪';

Always the result is the same 0 what can be the problem!?

  • Hi, By returning 0, do you mean no result is coming ? I don't know MAMP PRO but i think there is something wrong with your '٪' character. Can you try with the character '%' ? – Praveen E Nov 07 '17 at 09:53
  • yes you are right the problem is in the character, i don't know how is that possible and i'm writing the percentage character from the keyboard! –  Nov 07 '17 at 09:55
  • Okay then.. posting it as answer – Praveen E Nov 07 '17 at 09:56
  • `%` copy this character and paste it in the terminal, then see the results – Arvind Katte Nov 07 '17 at 09:57

3 Answers3

1

You are using percent character from Arabic encoding, copy following character and all will be fine (or switch your keyboard on English based keyboard and then type):

%

BIOHAZARD
  • 1,937
  • 20
  • 23
0

I doubt that it returns 0 - I suspect you mean the queries return no rows. Also you did not provide any details of the records you expected the query to return.

Applying further guesswork, I think the first 2 queries are intended to return records where the username starts with zW - in which case you should be specify a wildcard in your literal, e.g.

SELECT * FROM userlogin WHERE username LIKE '٪w%';

From the manual:

With LIKE you can use the following two wildcard characters in the pattern:

% matches any number of characters, even zero characters.

_ matches exactly one character.

symcbean
  • 47,736
  • 6
  • 59
  • 94
0

Hi Walid Naceri You have wrong special character use %w% Like this

  • 2
    While this might be a valuable hint to solve the problem, a good answer also demonstrates the solution. Please [edit] to provide example code to show what you mean. Alternatively, consider writing this as a comment instead. – Toby Speight Nov 07 '17 at 12:44