Problems in a query in mysql - accentuation

Asked

Viewed 43 times

-1

Good morning, if I search "Memory" in an input,

I made a code to take the accent and is going to query like this: "Memoria"

Soon returns to me those who are "Memory" The problem is that my database also has words written "Memory"

I need, when consulting "Memory" (in the input)

Bring me both with and without accentuation The same for when consult "Memory"

My problem is I can’t change the Where, to take either one or the other.

The data is words created by a user, sometimes it places accentuation, sometimes not, then my database gets the alternating data.

  • 1

    If you want to return both "Memory" and "Memory" a simple query using LIKE already resolves (Example: SELECT * FROM WORDS WHERE WORD LIKE "Memory";) This example should return the two results. But one important piece of information that should be highlighted is that some Collations are case sensitive and others are not. .

  • 2
  • Hi, I already use the like %word% and it is not working, the problem should be in the same colation, is this that I use in the bank: latin1_swedish_ci but I can not solve, without changing the colation in the bank, after all it is working perfectly, it’s got to be a code on Where or something

1 answer

0

A somewhat risky way, as it can bring other data that have the same sequence of letters is:

SELECT * FROM palavras
WHERE palavra LIKE "mem%ria" 

But take the test to see if your case applies.

  • Hi buddy, this % I think interprets as a letter, and also words in this space right? I would need something pertaining to any character, like a "question mark?" , a joker character, any, I will test, if any character is the %, then ok, but if allow to put words between, then do not give

  • Ahh, how I apply this to a variable, how the code will understand where I put the % ?

  • missing a code for it to find the accent and replace with %, to take to query

  • is... yes he allows anything between that % as long as the rest is equivalent before and after him. In case you are putting the literal query inside the code, or the query is pulling a code variable inside it? Why in case you are putting the literal query, it will understand quietly

  • If you can give me the codes I’ll try to assist

Browser other questions tagged

You are not signed in. Login or sign up in order to post.