I have following tables in my database: courses
(whole data of sports classes), coursedata
(with copies of courses.title
and courses.description
-- needed for FULLTEXT
index / relevance search), sports
(list of sports), and courses_sports
(association table) -- see below.
Now I want to map the courses relevance based to the sports and to fill courses_sports
with this data automatically. It needs two steps.
Collect the data with an apporiate
SELECT
.Write the data to the association table.
This post is about the first step. I have some troubles writing the query. What I've tried:
SELECT
courses.id,
sports.id
FROM
courses
JOIN
coursedata ON coursedata.id = courses.coursedata_id
JOIN
sports ON MATCH (coursedata.title) AGAINST (sports.title) > 0
-- The test with
-- sports ON MATCH (coursedata.title) AGAINST ('Basketball') > 0
-- works.
This query is not working:
Error Code: 1210
Incorrect arguments to AGAINST
How to implement this mapping correctly?
Additional information: relevant tables
courses
Field Type Key
------------------ --------------- ------
id int(11) PRI
title varchar(100)
description varchar(1000)
coursedata_id int(11) UNI
...
coursedata
Field Type Collation Null Key
----------- ------------- --------------- ------ ------
id int(11) (NULL) NO PRI
title varchar(100) utf8_general_ci YES MUL
description varchar(1000) utf8_general_ci YES MUL
CREATE TABLE `coursedata` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) DEFAULT NULL,
`description` varchar(1000) DEFAULT NULL,
PRIMARY KEY (`id`),
FULLTEXT KEY `searchcoursetitle` (`title`),
FULLTEXT KEY `searchcoursedescription` (`description`)
) ENGINE=MyISAM AUTO_INCREMENT=5208 DEFAULT CHARSET=utf8
sports
Field Type Collation Null Key
-------- --------------------- --------------- ------ ------
id int(11) (NULL) NO PRI
title varchar(50) utf8_general_ci NO
category varchar(50) utf8_general_ci YES
type enum('sport','dance') utf8_general_ci YES
courses_sports
Field Type Collation Null Key
--------- ------- --------- ------ ------
course_id int(11) (NULL) NO PRI
sport_id int(11) (NULL) NO PRI