December 24, 2008 at 9:08 am
hello frnds,
i have three tables namely,
account_details Columns: username,password
personal_details Columns:username,fname,laname,mailid
question_details Columns:usename,qid,questions,answers
now i want to get no.of questions from question_details of all users for that i tried a query is
"select count(question_details.username) as postcount,* from personal_details,question_details where personal_details.username and question_details.username in(select username from account_details)"
but its not useful for me,it throws some error... can anyone knows solution plz help me..
thank u...
December 24, 2008 at 9:30 am
I think this meets your needs:
[font="Courier New"]SELECT
COUNT(QD.qid) AS postcount,
PD.username,
PD.laname,
PD.fname,
PD.mailid
FROM
personal_details PD JOIN
question_details QD ON
PD.username = QD.username
WHERE
EXISTS (SELECT 1 FROM account_details WHERE username = PD.username)
GROUP BY
PD.username,
PD.laname,
PD.fname,
PD.mailid[/font]
You really don't need the Where clause unless you have person_detail rows without a matching username in account_details.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
December 25, 2008 at 8:48 pm
hey thanks a lot frnd...Ur query is working fine..
i have another need also...
In previous i mentioned three tables
account_details Columns: username,password
personal_details Columns:username,fname,laname,mailid
question_details Columns:usename,qid,questions,answers
and i asked personal details and message count from those table,
now i also need blog count from table by using this table,
blog_details Columns:usename,blogid,blogs,blog_solution
can u help me...thanks..
December 25, 2008 at 8:54 pm
If you are managing/programming this system you should be able to figure out the solution based on the previous solution I provided. I suggest you get yourself a beginners SQL query book like, Microsoft® SQL Server® 2008 T-SQL Fundamentals.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
December 25, 2008 at 9:43 pm
hey frnd dont get mistaken me...
i need to get message count from question_details,blogs count from blog_detail,personal information from personal_details of all user who are in account_details table.
account_details Columns: username,password
personal_details Columns:username,fname,laname,mailid
question_details Columns:usename,qid,questions,answers
blog_detail Columns:username,blogid,blogs,blog_solution
i dont want to get blog count from blog_detail table alone frnd..
December 26, 2008 at 10:57 am
Please see this article on how to get better results from these forums: http://www.sqlservercentral.com/articles/Best+Practices/61537/
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
December 26, 2008 at 11:10 am
sadaiyan,
People here volunteer their time and skill, and we are happy to try and help, but we expect you to try and do some work. We expect you to make an attempt and post code, not just ask for someone to do your work for you.
Jack gave you a hint, you can should try to work with that, or ask another question about something you don't understand, but this isn't rent a coder. You have a query you can use to try, so please do so and do not get upset when we ask you to do some work yourself.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply