Ho due tabelle:partita mysql contro non restituisce i risultati di casi insensitive
CREATE TABLE IF NOT EXISTS `test1` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`bucket_id` int(10) unsigned NOT NULL COMMENT 'folder this component belongs to',
`test1_name` varchar(81) NOT NULL COMMENT 'Name of this component',
`test1_desc` varchar(1024) NOT NULL COMMENT 'Component Description',
PRIMARY KEY (`id`),
FULLTEXT KEY `test1_search` (`test1_name`,`test1_desc`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
CREATE TABLE IF NOT EXISTS `bucket` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`bkt_name` varchar(81) NOT NULL COMMENT 'The name of this bucket',
`bkt_desc` varchar(1024) NOT NULL COMMENT 'A description of this bucket',
`bkt_keywords` varchar(512) DEFAULT NULL COMMENT 'keywords for searches',
PRIMARY KEY (`id`),
FULLTEXT KEY `fldr_search` (`bkt_desc`,`bkt_keywords`,`bkt_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
benna è solo un supporto mentre test1 contiene tutte le cose che andrebbero in un secchio. Per esempio:
INSERT INTO `bucket` (`id`, `bkt_name`, `bkt_desc`, `bkt_keywords`) VALUES
(1, 'Simpsons', 'The Simpsons Cartoon Family was first successful adult cartoon series', 'Homer, Marge, Lisa and Bart'),
(2, 'Griffins', 'The family from the popular family guy series', 'Peter, Lois, Meg, Chris, Stewie, Brian');
INSERT INTO `test1` (`id`, `bucket_id`, `bkt_name`, `bkt_desc`) VALUES
(1, 1, 'Homer Simpson', 'Homer the figurative head of the Simpsons Family and is the husband of Marge'),
(2, 2, 'Peter Griffin', 'Peter the figurative head of the Griffin family on the hit TV seriers The family Guy');
Ora, utilizzando la seguente query voglio guardare per tutti i secchi il cui nome, descrizione e parole chiave contengono il termine "famiglia" di ricerca o le cui componenti contengono le parole "famiglia")
Finora, quello che ho è questa query e non restituisce risultati di casi misti come in "Famiglia" non si trova mentre "famiglia" è.
SELECT *
FROM bucket
RIGHT JOIN test1 ON test1.bucket_id = bucket.id
WHERE
bucket.isvisible > 0 AND
MATCH(bucket.bkt_keywords, bucket.bkt_desc, bucket.bkt_name)
AGAINST('family' IN BOOLEAN MODE) OR
MATCH(test1.test1_name, test1.test1_desc)
AGAINST('family' IN BOOLEAN MODE)
Dovrei anche aggiungere che tutti i campi di testo hanno la collazione di utf8_general_ci come fa l'intera tabella che è MyISAM.
L'esempio fornito ha "famiglia" in minuscolo sia nella descrizione del secchio che nella descrizione del test. Puoi fare un esempio migliore per dimostrare il tuo problema? – scwagner
FYI, i nomi dei campi nell'istruzione di inserimento per test1 non sono corretti (dovrebbe essere 'test1_name',' test1_desc'). Anche SELECT ha bucket.isvisible> 0, che non è incluso nella tabella di esempio. Una volta che ho risolto queste due cose, però, la query ha restituito entrambe le righe, quindi purtroppo non conosco la causa del tuo problema reale. (A meno che l'intera faccenda del capitale non sia una falsa pista, e il vero problema è quel parametro bucket.isvisible nella riga dei simpson!) –
Anche tu potresti semplificare la query in questo modo: SELECT * FROM bucket RIGHT JOIN test1 ON test1 .bucket_id = bucket.id DOVE MATCH (bucket.bkt_keywords, bucket.bkt_desc, bucket.bkt_name, test1.test1_desc, test1.test1_name) CONTRO ('famiglia' IN MODO BOOLEAN) –