PDA

View Full Version : search not only by description, but with file name


jinger
11-28-2003, 05:23 AM
hi, :D

i have a search engine tat is able to search in mysql database for by the file description , but i want to add an additional feature tat is able to search for the file_name as well..

i tried adding the file_name field name into the condition query below with the OR CLAUSE, but alot of irrelvent results would appear. the same file will be listed out more than once.

codes:

select file_group_url.g_url,
file_record.file_desc,
file_record.file_name,
date_format(file_record.file_date_create,'%w-%m-%y'),
file_group_url.g_groupfrom file_record,
file_group_url
where file_record.G_id = file_group_url.G_id
and file_record.File_desc like'%'(user_id session value)
or file_record.File_name like'%'(user_id session value)


can anyone help to tell me how to correct the sql queries..

thanks in advance!

raf
11-28-2003, 10:26 PM
you can use
$sql = "SELECT DISTINCT ....."

to only get unique records. But it's better to build a fulltext index on file_desc and file_name and then run a full text search.
http://www.mysql.com/doc/en/Fulltext_Search.html

jinger
12-01-2003, 02:54 AM
when i use the "select DISTINCT" function,
i get the correct one record from the database to be listed, but i have a count * function which shows me that i have got 61 records found...

the multiple same record listing problem still happen to the File_desc.. hmm...

how can i solve this problem?:confused:

pls help..

raf
12-03-2003, 02:27 AM
I don't undersand the problem. Can you clarify some more.

Also, are you sure the count is correct.

jinger
12-05-2003, 02:24 AM
thank u all! everything is working finely now...

:thumbsup: