User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 427,159 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,889 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser: Programming Forums
Views: 2551 | Replies: 1
Reply
Join Date: Jun 2005
Posts: 1
Reputation: RammaR is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
RammaR RammaR is offline Offline
Newbie Poster

Query Troubles

  #1  
Jun 2nd, 2005
I'm trying to generate a search results page for a simple forum type page. My problem is that I'm searching the post content for the inputed keywords and then return a distinct list of the threads because often there are mutliple search hits within a common thread. So what I've done is a main query for the search with then pulls in all of the user/thread/forum data. Then do a 'distinct' query of queries on those results to filter out the multiple thread listings. So i might get 15 hits in 10 threads, which is working fine. However when I go to display the results I'm having trouble using that distinct list, everything I'm trying seems to show all 15 with repeats instead of 10.

for this example the query structure is like this:

<CFQUERY NAME='keywordsearch' ...>
SELECT (needed fields)
FROM (proper tables)
WHERE post_content LIKE'%#i#%'
</CFQUERY>

<CFQUERY DBTYPE = "query" NAME="thread_count_query">
SELECT DISTINCT thread_ids
FROM keywordsearch
</CFQUERY>

<CFQUERY NAME="populate_results_list" DBTYPE="query" MAXROWS="#records_per_page#">
<trying to determine what fits here, originally:>
SELECT DISTINCT unique_thread_ids, *
FROM keywordsearch
</CFQUERY>

Any tips or input would be greatly appreciated,
thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2003
Location: Malaysia
Posts: 313
Reputation: red_evolve is on a distinguished road 
Rep Power: 6
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: Query Troubles

  #2  
Jun 8th, 2005
Hi, there. I tried the same concept with some tables in my database.

select distinct a.jid from
(select journals.id as jid, entries.id as eid, content as con
from journals, entries 
where content like '%the%'
and entries.jid = journals.id)a 

Inside a, I'd get 9 records, 5 records from Journal1 with the keyword "the", and 4 records from Journal2 with the keyword "the".
After that, with select distinct a.jid from a, I get the ids for Journal1 and Journal2.
Basically, it's working for me.
"Study the past if you would define the future" - Confucius
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ColdFusion Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ColdFusion Forum

All times are GMT -4. The time now is 8:15 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC