searching database

I have a table that has bug(description,subject or something). i want to search it by keyword.

for example, a user enters "compatibility with Internet Explorer".

i want to find "compatibility" word and "Internet Explorer" from the table. then should i make a string array

like

String[] keywords = {"compatibility", "Internet Explorer"};

and search like this?

List result = new ArrayList();

for( int i = 0; i < keywords.length; i++ )

{

String sql = "select * from table where %description% = keywords;

String searchResult = search(sql);

result.add(searchResut);

}

i am kind of stuck in making an array with user's input and searching by keyword... please help...

Thanks in advance...

[787 byte] By [caesarkim1a] at [2007-9-29 19:03:33]
# 1

This is a SQL question and maybe you should look into SQL tutorials for this since the key to solvng your problem is to make a valid SQL statement that represents your query.

The following SQL Query would return all rows that had the two keywords in the record 'description':

List result = new ArrayList();

if(keywords.length == 0) {

throw new Exception("You must supply at least one keyword.");

}

else {

String SQL = "SELECT * FROM table WHERE";

for( int i = 0; i < keywords.length; i++ ) {

if(i > 0) sql = sql + " OR";

sql = sql + " description LIKE '"+keywords[0]+"'";

}

String searchResult = search(sql); // I guess this performs a query :)

}

BramFokkea at 2007-7-15 19:30:07 > top of Java-index,Other Topics,Algorithms...
# 2
And of course, keywords[0] should be keywords.
BramFokkea at 2007-7-15 19:30:07 > top of Java-index,Other Topics,Algorithms...
# 3
*must... use... preview... function*Sorry:[i] is a tag :-Skeywords[0] should be keywords[i].
BramFokkea at 2007-7-15 19:30:07 > top of Java-index,Other Topics,Algorithms...