Question

I have a database that contains both Hebrew and English. Unfortunately, the man who created the Data-base did a crappy job. I need to select rows that don't contain any Hebrew in them. Does SQL/MYSQL have a way of doing that?

Était-ce utile?

La solution

This depends a lot on the character set being used for storing the data. A guess would be that it is UTF8 encoded. UTF8 encoding has a particular characteristic that is useful for this purpose: ASCII characters (the kind we use in English) are only one byte. Hebrew characters would require more than one byte.

So, you can try this:

where char_length(col) = length(col)

If you know that the strings always begin with an alphabetic character, then something like:

where left(col1, 1) between 'a' and 'z'

might also work.

Autres conseils

Hi As the the column contain both english and Hebrew the data type must be nvarchar,

In SQL SERVER I DID THIS

SELECT CASE 
    WHEN CHARINDEX('?',CONVERT(VARCHAR,'2232d@❤##'))>0 THEN 'YES' 
    ELSE 'NO' 
END

this will tell you if a value is hebrew if yes else in english.

Use Locate in place of Char Index

Please let me know if this is of any help.

I am just giving you an upper idea. If you need any further help please tell.

Regards

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top