Note that there are some explanatory texts on larger screens.

plurals
  1. POJava: How do I retrieve a string from a full text search in mysql
    primarykey
    data
    text
    <p><strong>Edit 4: the problem came from using the string name of the column instead of the column number as indicated below by nuzz</strong></p> <p>I've been searching all day and can't figure out how to get a full text search to return a string. It works fine when I type it directly into the mysql command prompt and also works fine if I just use SELECT username FROM user_info; but I get nothing with this.</p> <pre><code>String result = ""; String request = "SELECT username FROM user_info WHERE MATCH (username) AGAINST ('themanager');"; Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(request); while (rs.next()) { result += rs.getString("username") ; result += "\n"; } </code></pre> <p>Edit 1: Here's the code for the table:</p> <pre><code> Create table user_info ( username varchar(16), password varchar(16), email varchar(16), PRIMARY KEY(username,email)); ALTER table user_info add FULLTEXT(username,email); </code></pre> <p>Sorry I'm still new to this and have no clue how to copy the code from desc user_info without posting a print screen.</p> <p>Edit 2: oops wrong code, same problem though.</p> <p>Edit 3: Just figuered out how to copy the desc. The output gives me all the users in the database for SELECT username FROM user_info;. I haven't a clue about the specifics of my database system just in that its a default install of mysql.</p> <pre><code>+-----------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+-------------+------+-----+---------+-------+ | username | varchar(16) | NO | PRI | | | | password | varchar(16) | YES | | NULL | | | email | varchar(50) | NO | PRI | | | +-----------------+-------------+------+-----+---------+-------+ </code></pre>
    singulars
    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.
 

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