Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP 5.3
|
BOOK: Beginning PHP 5.3
This is the forum to discuss the Wrox book Beginning PHP 5.3 by Matt Doyle; ISBN: 978-0-470-41396-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP 5.3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 21st, 2011, 01:12 AM
Authorized User
 
Join Date: Jun 2011
Posts: 51
Thanks: 9
Thanked 0 Times in 0 Posts
Send a message via MSN to nawar youssef
Default is it wrong if we use this sql statement ..

is it wrong if we use this sql statement
Code:
SELECT gender, sum(numVisits) AS TotalPagesView FROM members m, accessLog al WHERE m.id =al.memberId GROUP BY m.gender;
instead of what the book tells us to write :
Code:
SELECT m.gender, sum(al.numVisits) AS TotalPagesView FROM members m, accessLog al WHERE m.id =al.memberId GROUP BY m.gender;
and why if anybody know the answer thank you
 
Old October 21st, 2011, 02:56 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

Simply yes.

The book syntax is the correct way to do it as your using an alias m for the members table and as such referencing the gender field from the members table by using m.gender.

The way you have written it;

- which table is the gender field in?
- which table is the numVisits field in?

So now you want SQL to be a mind reader.... ;)
The Following User Says Thank You to UseLess For This Useful Post:
nawar youssef (October 21st, 2011)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is wrong of my alert statement? Edward King Javascript How-To 1 May 28th, 2005 05:12 AM
What is wrong with this insert statement? method SQL Server 2000 13 April 27th, 2005 11:46 PM
What's wrong with this statement ? levinll SQL Language 4 April 29th, 2004 08:41 PM
What's wrong with this SQL Statement dc925 ADO.NET 4 January 23rd, 2004 11:27 AM
What's wrong with my SQL statement? kaz VS.NET 2002/2003 1 December 11th, 2003 09:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.