473,511 Members | 15,852 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving details of last posts

1 New Member
OK guys hope this isnt to below you all but im new to msql and would appreciate some help.

I have the following tables

forum_frm (ALIAS = F)
##########################
# id_frn # title_frm # desc_frm #
##########################
# 01 # NEWS # blahblahblah #
# 02 # HELP # blahblahblah #
# 03 # FAQS # blahblahblah #
##########################

topics_top (ALIAS = T)
#######################
# id_top # idfrm_top # title_top #
#######################
# 01 # 01 # new rel.. #
# 02 # 01 # update.. #
# 03 # 02 # stuck ... #
# 04 # 03 # install... #
# 05 # 02 # missing.. #
# 06 # 02 # cant se.. #
# 07 # 03 # removi... #
#######################

messages_msg (ALIAS = M)
###########################################
# id_msg # idfrm_msg # idtop_msg # date_msg # idusr_msg #
###########################################
# 01 # 01 # 01 # 02-03-2005 # 01 #
# 02 # 01 # 02 # 03-04-2005 # 01 #
# 03 # 01 # 01 # 15-04-2005 # 02 #
# 04 # 02 # 03 # 16-04-2005 # 03 #
continued.....

user_usr (ALIAS = U)
###############
# id_usr # name_usr #
###############
# 01 # Peter #
# 02 # Joe #
# 03 # Kate #
continued.....

From these tables I require a query to get a table that resembles this....

################################################## #######################################
# F.title_frm # F.desc_frm # topics count # post count # date of last post # last post title # last post by #
################################################## #######################################

With this query :
SELECT F.title_frm, F.desc_frm,
count(DISTINCT T.id_top) AS topiccnt,
count(DISTINCT M.id_msg) AS postcnt,
max(M.date_msg) AS lastpost,
T.title_top, U.name_usr
FROM
(((forum_frm F LEFT JOIN topic_top T ON T.idfrm_top=F.id_frm)
LEFT JOIN message_msg M ON M.idtop_msg=T.id_top)
LEFT JOIN user_usr U ON U.id_usr=M.idusr_msg)
GROUP BY F.index_frm
This returns everything correctly apart from the "last post by" and "last post title". Mysql favouring the entries for the first post of each forum.

I hope someone can understand my explanation as it was a headache just writing it.

Anyway any help would be greatly appreciated

Thanks
Feb 6 '06 #1
0 1189

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1484
by: steve | last post by:
I have a comments form that when filled in posts the comments from a text field into a database. Due to a bit of duff coding (Doh!) the database was not getting updated and i lost 50 or so posts...
0
307
by: oliver james | last post by:
Having recently upgraded to Access 2002 at work, we have encountered the error message "Problem retrieving printer information for this object". Looking back through earlier posts, it appears that...
1
1895
by: oliver james | last post by:
Having recently upgraded to Access 2002 at work, we have encountered the error message "Problem retrieving printer information for this object". Looking back through earlier posts, it appears that...
2
1022
by: Richard Steele (Basemap) | last post by:
Hi I need to develop a ASP.net (c#) app that responds to a user sending a request i.e. from another website something like...
2
15682
by: Sakke | last post by:
Hello! We have written a GCryptoSvr.dll COM server in C++. Inside that resides WebClient COM component. WebClient CLSID is {8DC27D48-F94C-434B-A509-C3E1A3E75B9E}. When we are using that...
1
9434
by: jimmyfo | last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published (using VS2005 Publish feature) it to a relatively clean machine with ASP.Net 2.0 and MDAC 2.8 installed on it. However, when...
2
1193
by: Nemisis | last post by:
hi all, If i have a table in my database, and that table contains foreign keys to other tables, should i extract the data from the other tables at the same time, or should my business layer call...
7
4680
by: rfinch | last post by:
Very new to this but using the MS working with dynamics CRM 3.0 book to run web application to retrieve lead records from CRM 3.0. Have followed the book instructions on page 380-382. But am...
3
2163
by: Bruno Vignola | last post by:
Good Morning all, I need to interoperate with the Calendar of MS Outlook 2003 (inserting, retrieving, listing events, etc. etc.) from an ASP.NET application; I first developed a simple windows...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.