Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: Database: MS Access
 Multiple Inserts
 New Topic  Topic Locked
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 31 August 2007 :  09:10:12  Show Profile  Send ruirib a Yahoo! Message
Ok, even more efficient

SELECT 1 FROM FORUM_TOPICS WHERE EXISTS 
  (Select TOPIC_ID from FORUM_TOPICS T INNER JOIN FORUM_FORUM F ON T.FORUM_ID=F.FORUM_ID where F.F_TYPE = 2)
UNION 
SELECT 1 FROM FORUM_REPLY WHERE EXISTS 
   (SELECT REPLY_ID from FORUM_REPLY R INNER JOIN FORUM_FORUM F ON R.FORUM_ID=F.FORUM_ID where F.F_TYPE = 2)



Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 31 August 2007 :  09:24:25  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Its just a simple select. I will already know the word I'm looking for and just need the good and bad frequency of it. i.e.
select gFrequency, bFrequency from forum_spam where word = 'myword'
and then use
if not rs.BOF or rs.EOF etc

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 31 August 2007 :  09:26:21  Show Profile  Send ruirib a Yahoo! Message
Now you lost me... First you select messages, now you're using another table... If you tell exactly what you need, it will be easier.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 31 August 2007 :  09:43:39  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
I think you've already given me what I need but I need to test it.

I want to get a recordset of all good (F_TYPE=0) or bad (F_TYPE=2) topics and replies. I want to loop through all these rows of topics and replies and process the words in each T_MESSAGE or R_MESSAGE. I wrote a function getWords which takes a string argument i.e. getWords(T_MESSAGE) and returns an array of all words along with their frequency. I want to loop through this array and adjust the forum_spam table accordingly i.e. new words (and frequency) will be inserted and existing words (which will adready have a frequency) will be updated with their new frequency.

Sorry for the confusion, I don't need to know if a word exists in the forum_topics or forum_reply tables, I just need to know if it exists on the forum_spam table. That bit is simple (even for me).

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 31 August 2007 :  09:46:10  Show Profile  Send ruirib a Yahoo! Message
Okie dokie.

No need to apologize, as long as my replies helped you with what you need, I'm happy :).


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 31 August 2007 :  09:53:29  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
It works but I need to use UNION ALL in case of duplicates.

Might have a demo up over the weekend.

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 31 August 2007 :  10:12:14  Show Profile  Send ruirib a Yahoo! Message
Yep, UNION removes duplicate records from the final result set.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 31 August 2007 :  10:18:05  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
... and is slower than UNION ALL. I remember that from one other time you helped me.

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 31 August 2007 :  10:19:16  Show Profile  Send ruirib a Yahoo! Message
quote:
Originally posted by Podge

... and is slower than UNION ALL. I remember that from one other time you helped me.


Yep, I guess that's because all the records need to be scanned for duplicate removal.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 31 August 2007 :  14:12:25  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Is there a more efficient way of getting the count of all rows returned for this query other than executing it ?
Select T_MESSAGE from FORUM_TOPICS T INNER JOIN FORUM_FORUM F ON T.FORUM_ID=F.FORUM_ID where F.F_TYPE = 2
UNION 
SELECT R_MESSAGE from FORUM_REPLY R INNER JOIN FORUM_FORUM F ON R.FORUM_ID=F.FORUM_ID where F.F_TYPE = 2

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 31 August 2007 :  14:31:22  Show Profile  Send ruirib a Yahoo! Message
Valid for MySQL 4.1+

SELECT Sum(Result) FROM (
Select COUNT(TOPIC_ID) As Result from FORUM_TOPICS T INNER JOIN FORUM_FORUM F ON T.FORUM_ID=F.FORUM_ID where F.F_TYPE = 2
UNION
SELECT COUNT(REPLY_ID)As Result from FORUM_REPLY R INNER JOIN FORUM_FORUM F ON R.FORUM_ID=F.FORUM_ID where F.F_TYPE = 2
) As MyTable


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000 Version 3.4.07