|
Joined: Sep 2003
Posts: 19
Newbie
|
Newbie
Joined: Sep 2003
Posts: 19 |
Say I want to email all members who have 0 posts?
Say I want to email all members who have 0 posts and are in a certain group?
Would there be an SQL command that would yield EMAIL addresses instead of usernames? And is there a way to do these compound queries?
|
|
|
|
Joined: Mar 2001
Posts: 644
Member
|
Member
Joined: Mar 2001
Posts: 644 |
<br />SELECT U_Email <br />FROM `w3t_users` <br />WHERE U_Totalposts = 0 <br /> Or <br />SELECT U_Email <br />FROM `w3t_users` <br />WHERE U_Totalposts = 0 and (U_Groups LIKE '%3%') <br /> Second statement, replace the 3 with the group number you are looking for.
|
|
|
|
Joined: Sep 2003
Posts: 19
Newbie
|
Newbie
Joined: Sep 2003
Posts: 19 |
The first argument resulted in this error set: -------------------------------- SQL ERROR: Unable to do_query: SELECT U_Email FROM `w3t_users` WHERE U_Totalposts = 0 Table 'digitalw_threadtest.w3t_users' doesn't exist Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in /home/digitalw/public_html/ubbthreads/mysql.inc.php on line 165
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/digitalw/public_html/ubbthreads/mysql.inc.php on line 131 ---------------------------- The second resulted in.... ---------------------------- SQL ERROR: Unable to do_query: SELECT U_Email FROM `w3t_users` WHERE U_Totalposts = 0 and (U_Groups LIKE '%7%') Table 'digitalw_threadtest.w3t_users' doesn't exist Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in /home/digitalw/public_html/ubbthreads/mysql.inc.php on line 165
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/digitalw/public_html/ubbthreads/mysql.inc.php on line 131 ------------------------- Am I missing something?
|
|
|
|
Joined: Apr 2001
Posts: 3,266
Member
|
Member
Joined: Apr 2001
Posts: 3,266 |
Yes The error is simple
Zarzal forgot he is on a windows server. They by default make table names non capital Try these commands
SELECT U_Email
FROM `w3t_Users`
WHERE U_Totalposts = 0
Or
Code:
SELECT U_Email
FROM `w3t_Users`
WHERE U_Totalposts = 0 and (U_Groups LIKE '%3%')
|
|
|
|
Joined: Jun 2003
Posts: 1,025
Junior Member
|
Junior Member
Joined: Jun 2003
Posts: 1,025 |
Is your table prefix w3t? If so, then try w3t_Users. Otherwise change w3t to whatever your table prefix is.
|
|
|
|
Joined: Mar 2001
Posts: 644
Member
|
Member
Joined: Mar 2001
Posts: 644 |
I forgot to mention the table prefix thing. I expect that might be the problem. I'm on a windows server too Chuck, both those queries work for me. 
|
|
|
|
Joined: Sep 2003
Posts: 19
Newbie
|
Newbie
Joined: Sep 2003
Posts: 19 |
This works great. Another question: Is there an SQL command that will yield an email list of all the members in a certain group who were last on more than ..say.. two weeks ago?
|
|
|
|
Joined: Apr 2001
Posts: 3,266
Member
|
Member
Joined: Apr 2001
Posts: 3,266 |
SELECT t1.U_Email FROM w3t_Users AS t1, w3t_Last AS t2 WHERE t1.U_Number = t2.L_Uid AND L_Last > UNIX_TIMESTAMP( DATE_SUB( CURDATE( ) , INTERVAL 14 DAY ) ) AND t1.U_Groups LIKE '%-3-%'
|
|
|
|
Joined: Sep 2003
Posts: 19
Newbie
|
Newbie
Joined: Sep 2003
Posts: 19 |
The code in the above post yields a list of every email address in the group! And each email address is listed between 3 and 8 times.
I'm not sure if the code's wrong, or if I misstated what I'm looking for: The subset of a usergroup containing all members who haven't logged on in the past two weeks. The list I was looking for was about 30 emails. I got 500!: Everyone!
|
|
|
|
Joined: Apr 2001
Posts: 3,266
Member
|
Member
Joined: Apr 2001
Posts: 3,266 |
You where not clear on what you wanted  I took it you needed everybody who was on in the last two weeks. Besides when checking with the last table your going to get multiple entries. I mean you could write script to cycle through and only give one instance per email.
|
|
|
|
Joined: Sep 2003
Posts: 19
Newbie
|
Newbie
Joined: Sep 2003
Posts: 19 |
I didn't realize that multiple email addresses should be expected. Sorry for causing the confusion, and jumping to conclusions.
What changes would I make to the code above to get emails of group members who HAVEN'T been on the forum in the past two weeks?
|
|
|
|
Joined: Apr 2001
Posts: 3,266
Member
|
Member
Joined: Apr 2001
Posts: 3,266 |
As far as who has not been not been on in the last two weeks HMM SELECT U_Email FROM w3t_Users WHERE U_LastOn < UNIX_TIMESTAMP( DATE_SUB( CURDATE( ) , INTERVAL 14 DAY ) ) AND U_Groups LIKE '%-3-%' This would do what you want.
|
|
|
|
Joined: Sep 2003
Posts: 19
Newbie
|
Newbie
Joined: Sep 2003
Posts: 19 |
Worked like a charm-- I deeply appreciate it!
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 1,157
Joined: July 2001
|
|
Forums63
Topics37,575
Posts293,931
Members13,824
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|