|
Posted by J.O. Aho on 01/26/07 09:29
Niel Darren wrote:
> Hi,
>
> I am a total newbie with SQL-statements, but hope you can help me, i have a
> few questions:
>
> 1. How can i get the number of rows/records in a table with a SQL statement
> ?
As you are using php, you have *_num_rows() (replace the '*' with the SQL
server type you are using).
You can of course use COUNT(*) in the SQL SELECT.
> 2. I have a record looking like this:
> ID, TIMESTAMP (hh:mm:ss), datastring
This should work:
SELECT * FROM table WHERE timecolumn>20050517120000 AND timecolumn<20060517120000;
There are other date related ways to do it too, just check the online manual
at mysql.com.
> 3. Is it possible to do calculations ? i have another table with: ID,
> TIMESTAMP, graph x-point value
> Then i want to instruct it to extract from one time to another, and give
> me the average of all theese values (only asking if i can do it with SQL, if
> not i can do it with code ofcourse).
SELECT AVG(graph_x_poin) FROM table;
> Do you have a link to a PDF or similar resource that is useful for a SQL
> newbie so i could get an insight in SQL - as i said, i am not much into it.
http://dev.mysql.com/doc/refman/5.0/en/
--
//Aho
[Back to original message]
|