If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
I have a last question: how i can do to add the count(*) from two select?
my situation is this:
SELECT 4*COUNT(*) from Sell where month(date) = 10 and year(date) = 2005 + SELECT 12*COUNT(*) from services where month(date) = 10 and year(Date) = 2005
If you want to retrieve a sum, the + should come in the select statement. ie.
Code:
SELECT 4+1 AS five
or
Code:
SELECT ( (SELECT COUNT(*) FROM table1) + (SELECT MAX(field) FROM table2) ) AS sum
You can nest statements in your queries for more complexity. Judging from the query you replied with, you may also want to read up on other functions like SUM() and DATE_FORMAT().