944,125 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 3086
  • MySQL RSS
Feb 19th, 2007
0

MySQL query's

Expand Post »
Hi,
I am trying to understand MySQL as i am new to this and i have a few queries I am having problems with and I was wondering if anyone can help me with it.. How would you solve this problem using the Select, from, where etc commands.
For example if you were to Find out what the average cost of all the books in a book table is, how would you write it.. and also how to find out which book cost the MOST in a book table, how would you write it.. I have tried to write what i have thought but its not giving me any answer at all.. I am using MySQL query.. Thank you so much in advance for your help
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dami06 is offline Offline
90 posts
since Oct 2006
Feb 19th, 2007
0

Re: MySQL query's

Click to Expand / Collapse  Quote originally posted by dami06 ...
Hi,
I am trying to understand MySQL as i am new to this and i have a few queries I am having problems with and I was wondering if anyone can help me with it.. How would you solve this problem using the Select, from, where etc commands.
For example if you were to Find out what the average cost of all the books in a book table is, how would you write it.. and also how to find out which book cost the MOST in a book table, how would you write it.. I have tried to write what i have thought but its not giving me any answer at all.. I am using MySQL query.. Thank you so much in advance for your help
You should be using the avg and max functions.

So to get the average price

MySQL Syntax (Toggle Plain Text)
  1. SELECT avg(price) FROM books;

or the most expensive
MySQL Syntax (Toggle Plain Text)
  1. SELECT title, max(price) FROM books GROUP BY title ORDER BY max desc


/you may need to alter these slightly for mysql - i use postgresql these days
Last edited by pty; Feb 19th, 2007 at 11:44 am.
pty
Reputation Points: 64
Solved Threads: 39
Posting Pro
pty is offline Offline
530 posts
since Oct 2005
Mar 14th, 2007
0

Re: MySQL query's

Thank u so much...sorry for late reply
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dami06 is offline Offline
90 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: SQL Server 2005 version Error Insert command help me
Next Thread in MySQL Forum Timeline: MySQL a start point for future DBA role





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC