Not inserting Turkish characters in SQL table. Displays 'xxx??xxx' when selected - mysql

I am trying to add Turkish names on my table but then when displayed it gives me ? instead of any of them. Any help what I am missing here? This is my table:
CREATE TABLE IF NOT EXISTS `offerings` (
`dep` varchar(5) CHARACTER SET utf16 COLLATE utf16_turkish_ci DEFAULT NULL,
`grade` varchar(4) CHARACTER SET utf16 COLLATE utf16_turkish_ci DEFAULT NULL,
`section` varchar(3) CHARACTER SET utf16 COLLATE utf16_turkish_ci DEFAULT NULL,
`name` varchar(100) CHARACTER SET utf16 COLLATE utf16_turkish_ci DEFAULT NULL,
`teacher` varchar(50) CHARACTER SET utf16 COLLATE utf16_turkish_ci DEFAULT NULL,
`quota` varchar(2) CHARACTER SET utf16 COLLATE utf16_turkish_ci DEFAULT NULL,
`lec1` varchar(35) CHARACTER SET utf16 COLLATE utf16_turkish_ci DEFAULT NULL,
`lec2` varchar(35) CHARACTER SET utf16 COLLATE utf16_turkish_ci DEFAULT NULL,
`lec3` varchar(35) DEFAULT NULL,
`lec4` varchar(35) DEFAULT NULL,
`lec5` varchar(35) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf16;
As suggested from the answer I choose here is the solution to the problem for whoever googles this topic. Special thanks to all who contributed in the solution of my problem.
CREATE TABLE IF NOT EXISTS `offerings` (
`dep` varchar(5) NOT NULL,
`grade` varchar(4) COLLATE utf8_unicode_ci NOT NULL,
`section` varchar(3) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`teacher` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`quota` varchar(2) COLLATE utf8_unicode_ci,
`lec1` varchar(35) DEFAULT NULL,
`lec2` varchar(35) DEFAULT NULL,
`lec3` varchar(35) DEFAULT NULL,
`lec4` varchar(35) DEFAULT NULL,
`lec5` varchar(35) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

(Beginnings of an answer...)
Please don't use utf16; there is virtually no reason for such in a MySQL table.
So, assuming you switch to utf8, let's see if we can get rid of the ? problems.
utf8 needs to be established in about 4 places.
The column(s) in the database -- Use SHOW CREATE TABLE to verify that they are explicitly set to utf8, or defaulted from the table definition. (It is not enough to change the database default.)
The connection between the client and the server. See SET NAMES utf8.
The bytes you have. (This is probably the case.)
If you are displaying the text in a web page, check the <meta> tag.
What probably happened:
you had utf8-encoded data (good)
SET NAMES latin1 was in effect (default, but wrong)
the column was declared CHARACTER SET latin1 (default, but wrong)
Since the CHARACTER SET disagrees with what you have shown, the problem is possibly more complex. Please provide
SELECT col, HEX(col) FROM tbl WHERE ...
for some simple cell with Turkish characters. With this, I may be able to figure out what happened.
Also, Reference notes on encodings.

VARCHARs are character strings, while NVARCHARS are Unicode character strings. NVARCHARS require more bits per character to store, but have a greater range. Try updating your data types. This should fix your problem.
EDIT This answer is wrong. The OP clearly asked for a MySQL solution, but the above applies only to SQL Server.

Related

MYSQL Stored Procedure - Concat Row Value (continued)

Update / Answer
To fix this issue, I added the keyword BINARY to each side of the comparison operator. This generated the expected results. Also note that I set the variable to empty string. Setting this to NULL did not resolve the issue.
SET #previousstate = '';
SELECT
if(**BINARY** #previousstate != **BINARY** frm.fi_details_temp.PortfolioCode,
End Update / Answer
This is somewhat related to MYSQL Stored Procedure - Concat Row Value. That thread was based on Mysql 5.7.
The following statement worked under MySQL 5.7. I am in the process of trying to get it to work in MySql 8. I had to update the SET statement to 'SET #previousstate = NULL;' otherwise I get "Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8mb4_unicode_ci,IMPLICIT) for operation '<>'". This error was way above my understanding. I am just a marketing guy working in a small firm. So that is why I set it to NULL.
With that said, after updating the SET statement the result set returns but the if() statement is not working like it did under 5.7. The very first row returned should have the first column of data marked with '*' at the beginning and end, and as the data in the column changes it should mark it too.
So it should look like this:
*brownfdn*
brownfdn
*brownfmi*
brownfmi
But I am getting this:
brownfdn
brownfdn
brownfmi
brownfmi
Do you have any thoughts about what I am doing wrong? I appreciate your help!! Getting to MySql 8 has been a struggle.
5.7
CREATE table fi_details_temp AS (
SELECT
frm.fi_details.PortfolioCode,
frm.fi_details.MaturityDate_Final
From
frm.fi_details
Where
frm.fi_details.manager = 'Bartz' And
frm.fi_details.PortfolioCode Like ('Crown%')
Group By
frm.fi_details.PortfolioCode,
frm.fi_details.MaturityDate_Final
Order By
frm.fi_details.PortfolioCode;
SET #previousstate = '';
SELECT
if(#previousstate != frm.fi_details_temp.PortfolioCode, concat('*',#previousstate:= frm.fi_details_temp.PortfolioCode,'*'), frm.fi_details_temp.PortfolioCode) as 'Portfolio Code',
frm.fi_details_temp.MaturityDate_Final as 'Maturity Date'
From frm.fi_details_temp;
DROP TABLE IF EXISTS fi_details_temp;
END
*** Create Statements - the above was a trimmed down version ***
CREATE TABLE `fi_details` (
`id` int NOT NULL AUTO_INCREMENT,
`RecordDate` datetime DEFAULT CURRENT_TIMESTAMP,
`PortfolioCode` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`manager` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`RunDate` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`RunDate_Final` date DEFAULT NULL,
`AsOfDate` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`AsOfDate_Final` date DEFAULT NULL,
`Symbol` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Coupon` double DEFAULT NULL,
`MaturityDate` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`MaturityDate_Final` date DEFAULT NULL,
`ParValue` double DEFAULT NULL,
`MarketValue` double DEFAULT NULL,
`AdjustedUnitCost` double DEFAULT NULL,
`TotalAdjustedCost` double DEFAULT NULL,
`SPRating` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`MoodyRating` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`YieldCost` double DEFAULT NULL,
`YieldMarket` double DEFAULT NULL,
`YieldCall` double DEFAULT NULL,
`YieldPut` double DEFAULT NULL,
`YieldWorst` double DEFAULT NULL,
`WorstDate` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`WorstDate_Final` date DEFAULT NULL,
`CallDate` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`CallDate_Final` date DEFAULT NULL,
`CallPrice` double DEFAULT NULL,
`PutDate` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`PutDate_Final` date DEFAULT NULL,
`PutPrice` double DEFAULT NULL,
`FirstCouponDate` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`FirstCouponDate_Final` date DEFAULT NULL,
`LastCouponDate` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`LastCouponDate_Final` date DEFAULT NULL,
`Freq` int DEFAULT NULL,
`BondCalendarCode` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`SecTypeCode` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`Security` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_fi_details_MaturityDate_Final` (`MaturityDate_Final`),
KEY `idx_fi_details_PortfolioCode` (`PortfolioCode`),
KEY `idx_fi_details_PortfolioCode_MaturityDate_Final` (`PortfolioCode`,`MaturityDate_Final`),
KEY `idx_fi_details_manager_MaturityDate_Final` (`manager`,`MaturityDate_Final`),
KEY `idx_fi_details_MaturityDate_Final_manager` (`MaturityDate_Final`,`manager`)
) ENGINE=InnoDB AUTO_INCREMENT=234850 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE DEFINER=`root`#`localhost` PROCEDURE `fi_details_Worst_Date_Hartz_Brown`()
BEGIN
DROP TABLE IF EXISTS fi_details_temp;
CREATE table fi_details_temp AS (
SELECT
frm.fi_details.PortfolioCode,
frm.fi_details.MaturityDate_Final,
frm.fi_details.YieldWorst,
frm.fi_details.WorstDate_Final,
frm.fi_details.YieldMarket,
frm.fi_details.Symbol,
frm.fi_details.Security,
frm.fi_details.Coupon,
frm.fi_details.ParValue,
frm.fi_details.MarketValue,
frm.fi_details.TotalAdjustedCost,
frm.fi_details.AdjustedUnitCost,
frm.fi_details.YieldCost,
frm.fi_details.YieldCall,
frm.fi_details.YieldPut,
frm.fi_details.CallDate_Final
From
frm.fi_details
Where
frm.fi_details.manager = 'Hartz' And
frm.fi_details.PortfolioCode Like ('Brown%')
Group By
frm.fi_details.PortfolioCode,
frm.fi_details.MaturityDate_Final,
frm.fi_details.YieldWorst,
frm.fi_details.WorstDate_Final,
frm.fi_details.YieldMarket,
frm.fi_details.Symbol,
frm.fi_details.Security,
frm.fi_details.Coupon,
frm.fi_details.ParValue,
frm.fi_details.MarketValue,
frm.fi_details.TotalAdjustedCost,
frm.fi_details.AdjustedUnitCost,
frm.fi_details.YieldCost,
frm.fi_details.YieldCall,
frm.fi_details.YieldPut,
frm.fi_details.CallDate_Final
Order By
frm.fi_details.PortfolioCode,
frm.fi_details.WorstDate_Final );
SET #previousstate = NULL;
SELECT
if(#previousstate != frm.fi_details_temp.PortfolioCode, concat('*',#previousstate:= frm.fi_details_temp.PortfolioCode,'*'), frm.fi_details_temp.PortfolioCode) as 'Portfolio Code',
frm.fi_details_temp.MaturityDate_Final as 'Maturity Date',
frm.fi_details_temp.YieldWorst as 'Worst Yield',
frm.fi_details_temp.WorstDate_Final as 'Worst Date',
frm.fi_details_temp.YieldMarket as 'Yield to Market',
frm.fi_details_temp.Symbol,
frm.fi_details_temp.Security as 'Description',
frm.fi_details_temp.Coupon,
frm.fi_details_temp.ParValue as 'Par Value',
frm.fi_details_temp.MarketValue as 'Market Value xAI',
frm.fi_details_temp.TotalAdjustedCost as 'Adjusted Cost',
frm.fi_details_temp.AdjustedUnitCost as 'Unit Adjusted Cost',
frm.fi_details_temp.YieldCost as 'Yield to Cost',
frm.fi_details_temp.YieldCall as 'Yield to Call',
frm.fi_details_temp.YieldPut as 'Yield to Put',
frm.fi_details_temp.CallDate_Final as 'Next Call Date'
From frm.fi_details_temp;
DROP TABLE IF EXISTS fi_details_temp;
END

Utf8 characters cut off when saving text field in mysql

I'm working on a website in which we save Japanese characters in a text field.
The table looks like this:
| contactlogs | CREATE TABLE `contactlogs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`contact_email` varchar(128) CHARACTER SET latin1 NOT NULL,
`name` varchar(128) CHARACTER SET latin1 DEFAULT NULL,
`company_name` varchar(128) CHARACTER SET latin1 DEFAULT NULL,
`email` varchar(128) CHARACTER SET latin1 DEFAULT NULL,
`telephone` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
`fax` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
`subject` text COLLATE utf8_unicode_ci NOT NULL,
`message` text COLLATE utf8_unicode_ci NOT NULL,
`created` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
When I retrieve the data that was saved, the message field is often cut off, with a garbage character at the end (I assume because it might not have saved all the data of the last character.
The website itself is in cakephp. The data is being saved by just doing a $this->model->save($data) (Haven't changed anything about the way it's saving, the model itself is empty). There's no special database settings. Just set host, login, persistent => false, driver => mysql, database, prefix.
Your DB and tables are probably under latin1 default collation, so without 'encoding' => 'utf8' in your database config cake is gonna be talking to the DB in latin1. The transcoding of UTF to latin1 and back leaves space for data to be lost. This is not really cake's problem.
So go on and change the connection to UTF and all default collations in the DB too. Newly saved data will be displayed fine, for old ones it will depend, I won't go into details cause it's out of context.

Mysql FullText Search Case-insensitive

I have table products_discription from OpenCart.
I created new search engine. Everything is okey, except that is case sensitive.
How I can make it insensitive.
I readed in Mysql Documentation I must change utf8_bin to utf8_general_ci.
But how to make it, without deleting all indexes.
Its not only one table. I'm looking for at 4 tables. Every table has around 4 -5 indexes.
The site brings non-stop information. Loss of information is simply not acceptable.
I was wondering if there is a way to extract keys to delete, and change the encoding. Then add them again with just one application. As such, I think that there will be no data loss.
CREATE TABLE IF NOT EXISTS `product_description` (
`product_id` int(11) NOT NULL,
`language_id` int(11) NOT NULL,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`short_description` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`description` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`meta_description` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`meta_keyword` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`tag` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`custom_title` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '',
PRIMARY KEY (`product_id`,`language_id`),
FULLTEXT KEY `description` (`description`),
FULLTEXT KEY `tag` (`tag`),
FULLTEXT KEY `ft_namerel` (`name`,`description`),
FULLTEXT KEY `name` (`name`,`short_description`,`description`,`meta_description`,`meta_keyword`,`tag`,`custom_title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
have you tried searching in boolean mode?
I deleted all index keys and change encoding, after that I set new index keys.

Problem with ColdFusion communicating with MySQL database

I have been working to migrate a non-profit website from a local server (running Windows XP) to a GoDaddy hosting account (running Linux). Most of the pages are written in ColdFusion. Things have gone smoothly, up until this point. There is a flash form within the site (see this page: http://www.preservenet.cornell.edu/employ/submitjob.cfm) which, when completed, takes the visitor to this page: submitjobaction.cfm . I'm not quite sure what to make of this error, since I copied exactly what had been in the old MySQL database, and the .cfm files are exactly as they had been when they worked on the old server. Am I missing something?
Below is the code from the database that the error seems to be referring to. When I change "Positionlat" to some default value in the database as it suggests in the error, it says that another field needs a default value, and it's a neverending chain of errors as I try to correct it.
This is probably a stupid error that I'm missing, but I've been working at it for days and can't find what I'm missing. I would really appreciate any help.
Thanks!
-Greg
DROP TABLE IF EXISTS `employopp`;
CREATE TABLE `employopp` (
`POSTID` int(10) NOT NULL auto_increment,
`USERID` varchar(10) collate latin1_general_ci default NULL,
`STATUS` varchar(10) collate latin1_general_ci NOT NULL default 'ACTIVE',
`TYPE` varchar(50) collate latin1_general_ci default 'professional',
`JOBTITLE` varchar(70) collate latin1_general_ci default NULL,
`NUMBER` varchar(30) collate latin1_general_ci default NULL,
`SALARY` varchar(40) collate latin1_general_ci default NULL,
`ORGNAME` varchar(70) collate latin1_general_ci default NULL,
`DEPTNAME` varchar(70) collate latin1_general_ci default NULL,
`ORGDETAILS` mediumtext character set utf8 collate utf8_unicode_ci,
`ORGWEBSITE` varchar(200) collate latin1_general_ci default NULL,
`ADDRESS` varchar(60) collate latin1_general_ci default 'none given',
`ADDRESS2` varchar(60) collate latin1_general_ci default NULL,
`CITY` varchar(30) collate latin1_general_ci default NULL,
`STATE` varchar(30) collate latin1_general_ci default NULL,
`COUNTRY` varchar(3) collate latin1_general_ci default 'USA',
`POSTALCODE` varchar(10) collate latin1_general_ci default NULL,
`EMAIL` varchar(75) collate latin1_general_ci default NULL,
`NOMAIL` varchar(5) collate latin1_general_ci default NULL,
`PHONE` varchar(20) collate latin1_general_ci default NULL,
`FAX` varchar(20) collate latin1_general_ci default NULL,
`WEBSITE` varchar(200) collate latin1_general_ci default NULL,
`POSTDATE` varchar(10) collate latin1_general_ci default NULL,
`POSTUNTIL` varchar(20) collate latin1_general_ci default 'select date',
`POSTUNTILFILLED` varchar(20) collate latin1_general_ci NOT NULL default 'until filled',
`texteHTML` mediumtext character set utf8 collate utf8_unicode_ci,
`HOWTOAPPLY` mediumtext character set utf8 collate utf8_unicode_ci,
`CONFIRSTNM` varchar(30) collate latin1_general_ci default NULL,
`CONLASTNM` varchar(60) collate latin1_general_ci default NULL,
`POSITIONCITY` varchar(30) collate latin1_general_ci default NULL,
`POSITIONSTATE` varchar(30) collate latin1_general_ci default NULL,
`POSITIONCOUNTRY` varchar(3) collate latin1_general_ci default 'USA',
`POSITIONLAT` varchar(50) collate latin1_general_ci NOT NULL,
`POSITIONLNG` varchar(50) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`POSTID`)
) ENGINE=MyISAM AUTO_INCREMENT=2007 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
UPDATE:
Where I think the "submitjobaction.cfm" page communicates with the database:
<CFINSERT DATASOURCE="mysqlcf_preservenet" TABLENAME="employopp" FORMFIELDS=" TYPE, JOBTITLE, NUMBER, SALARY, ORGNAME, DEPTNAME, ORGDETAILS, ORGWEBSITE, ADDRESS, ADDRESS2, CITY, STATE, COUNTRY, POSTALCODE, EMAIL, NOMAIL, PHONE, FAX, WEBSITE, POSTDATE, POSTUNTIL, texteHTML, HOWTOAPPLY, CONFIRSTNM, CONLASTNM, POSITIONCITY, POSITIONSTATE, POSITIONCOUNTRY">
<CFINSERT DATASOURCE="mysqlcf_preservenet" TABLENAME="user" FORMFIELDS=" ORGNAME, WEBSITE, ADDRESS, ADDRESS2, CITY, STATE, COUNTRY, POSTALCODE, EMAIL, PHONE, FAX, CONFIRSTNM, CONLASTNM" >
I use none of mysql, cfform or cfinsert so ymmv with this answer, but it seems like the problem is in the database configuration.
This blog post from 2007 suggests changing an ini setting for sql-mode. You'll need to talk to your host to check the current value and try to have it changed.
It looks like the form is sending zero-length values for unanswered fields and the database is rejecting those values.
Another approach is to replace the cfinsert with a normal cfquery - this will give you more flexibility with how you supply 'empty' values.
I get the following error message:
Error Executing Database Query.
Field 'CONFIRSTNM' doesn't have a default value
Resources:
...
What seems to happen here is that some form field (named CONFIRSTNM - I assume that's the Contact Firstname) is empty in the POST and the database doesn't have a default value set. Because your cf code is using CFINSERT you don't actually write the SQL code yourself but CF is supposed to do it for you. Hard to debug from the distance, but I think what you should do is to make sure the database was 1:1 migrated from the old environment to the new environment. Not sure how the migration was done, but it might have lost some information along the way.
Another suggestion for good coding practice is to rewrite CFINSERT with a CFQUERY tag and write the SQL statement yourself. Also make sure you use CFQUERYPARAM for all incoming parameters.

Mysql german accents not-sensitive search in full-text searches

Let`s have a example hotels table:
CREATE TABLE `hotels` (
`HotelNo` varchar(4) character set latin1 NOT NULL default '0000',
`Hotel` varchar(80) character set latin1 NOT NULL default '',
`City` varchar(100) character set latin1 default NULL,
`CityFR` varchar(100) character set latin1 default NULL,
`Region` varchar(50) character set latin1 default NULL,
`RegionFR` varchar(100) character set latin1 default NULL,
`Country` varchar(50) character set latin1 default NULL,
`CountryFR` varchar(50) character set latin1 default NULL,
`HotelText` text character set latin1,
`HotelTextFR` text character set latin1,
`tagsforsearch` text character set latin1,
`tagsforsearchFR` text character set latin1,
PRIMARY KEY (`HotelNo`),
FULLTEXT KEY `fulltextHotelSearch` (`HotelNo`,`Hotel`,`City`,`CityFR`,`Region`,`RegionFR`,`Country`,`CountryFR`,`HotelText`,`HotelTextFR`,`tagsforsearch`,`tagsforsearchFR`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci;
In this table for example we have only one hotel with Region name = "Graubünden" (please note umlaut ü character)
And now I want to achieve same search match for phrases:
'graubunden' and
'graubünden'
This is simple with use of MySql built in
collations in regular searches as follows:
SELECT *
FROM `hotels`
WHERE `Region` LIKE CONVERT(_utf8 '%graubunden%' USING latin1)
COLLATE latin1_german1_ci
This works fine for 'graubunden' and 'graubünden' and
as a result I receive proper result, but problem is
when we make MySQL full text search
Whats wrong with this SQL statement?:
SELECT
*
FROM
hotels
WHERE
MATCH (`HotelNo`,`Hotel`,`Address`,`City`,`CityFR`,`Region`,`RegionFR`,`Country`,`CountryFR`, `HotelText`, `HotelTextFR`, `tagsforsearch`, `tagsforsearchFR`)
AGAINST( CONVERT('+graubunden' USING latin1) COLLATE latin1_german1_ci IN BOOLEAN MODE)
ORDER BY Country ASC, Region ASC, City ASC
This doesn`t return any result.
Any ideas where the dog is buried ?
When you define individual CHARACTER SETS for your columns, you override the collation you set default on table level.
Each of your columns has default latin1 collation (which is latin1_swedish_ci). You can see it by running SHOW CREATE TABLE.
In FULLTEXT queries, indexed columns have COERCIBILITY of 0, that is all fulltext queries are converted to the collation used in the index, not vice versa.
You need to remove CHARACTER SET definitions from your columns or explicitly set all columns to latin1_german_ci:
CREATE TABLE `hotels` (
`HotelNo` varchar(4) NOT NULL default '0000',
`Hotel` varchar(80) NOT NULL default '',
`City` varchar(100) default NULL,
`CityFR` varchar(100) default NULL,
`Region` varchar(50) default NULL,
`RegionFR` varchar(100) default NULL,
`Country` varchar(50) default NULL,
`CountryFR` varchar(50) default NULL,
`HotelText` text,
`HotelTextFR` text,
`tagsforsearch` text,
`tagsforsearchFR` text,
PRIMARY KEY (`HotelNo`),
FULLTEXT KEY `fulltextHotelSearch` (`HotelNo`,`Hotel`,`City`,`CityFR`,`Region`,`RegionFR`,`Country`,`CountryFR`,`HotelText`,`HotelTextFR`,`tagsforsearch`,`tagsforsearchFR`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci;
INSERT
INTO hotels (hotelText, HotelTextFR, tagsforsearch, tagsforsearchFR)
VALUES ('text', 'text', 'graubünden', 'tags');
SELECT *
FROM hotels
WHERE MATCH (`HotelNo`,`Hotel`,`City`,`CityFR`,`Region`,`RegionFR`,`Country`,`CountryFR`, `HotelText`, `HotelTextFR`, `tagsforsearch`, `tagsforsearchFR`)
AGAINST (CONVERT('+graubunden' USING latin1) COLLATE latin1_german1_ci IN BOOLEAN MODE)
ORDER BY
Country ASC, Region ASC, City ASC;