Note that there are some explanatory texts on larger screens.

plurals
  1. POMysql Fulltext search with different number of columns
    primarykey
    data
    text
    <p>I've been taking my first stab at Fulltext searching and am having trouble getting the query to work. Here's the new code I've been trying (from a PHP file):</p> <pre><code>$browse_all_query = "(SELECT master_id, title, series_id, series_number, year, date, day, month, speaker_id, speaker2_id, speaker3_id " . "FROM master " . "WHERE MATCH (title) AGAINST ($where_clause)) " . "UNION " . "(SELECT camp_name, camp_id " . "FROM camp " . "WHERE MATCH (camp_name) AGAINST ($where_clause)) " . "UNION " . "(SELECT subject_name, subject_id " . "FROM subject " . "WHERE MATCH (subject_name) AGAINST ($where_clause)) " . "UNION " . "(SELECT speaker_id, s_title, f_name, m_name, l_name, l_name2 " . "FROM speaker " . "WHERE MATCH (s_title, f_name, m_name, l_name, l_name2) AGAINST ($where_clause)) " . "UNION " . "(SELECT series_title, series_id " . "FROM series " . "WHERE MATCH (series_title) AGAINST ($where_clause)) "; </code></pre> <p>Now, I understand that a big issue for me here is that I have different numbers of columns in my select statements as well as different data types. What I need is to figure out how I can pull all the information I need from all the columns I've selected, yet still use fulltext search. This is an online audio library. I'm using a regular WHERE/LIKE setup now, but unfortunately using that method, searching for one speaker's name (Glenn Clark) brings up results for "glenn" and "clark" wherever they are used as I sanitize and separate my keywords....not to mention that the "speaker" table has separate columns for first name and last name.</p> <p>What would be the best way around this?</p> <p>My table structure is:</p> <ol> <li>Master (the main table with 13 columns)</li> <li>Speaker (6 columns)</li> <li>Camp (3 columns)</li> <li>Series (6 columns)</li> <li>Subject (2 columns)</li> </ol> <p>In my current code I was selecting all the extra bits of information not directly relative to the search at the same time I ran the search, as I use those bits (like all the "id" fields) to output all the information I needed for the results as seen here: <img src="https://i.stack.imgur.com/HgNx2.jpg" alt="enter image description here"></p> <p>Am I needing additional queries or am I going about this completely the wrong way.</p> <p>Thank you for your help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload