Adding all tables together?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
robynprivette
Forum Commoner
Posts: 46
Joined: Sun May 02, 2010 6:22 pm

Re: Adding all tables together?

Post by robynprivette »

I know how many entries are in there... I want to show it to other people who use my site.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Adding all tables together?

Post by McInfo »

robynprivette wrote:i don't know how to do that
Does that mean you do have phpMyAdmin? There is a tab in phpMyAdmin where you can run SQL queries.
screenshot.png
screenshot.png (29.05 KiB) Viewed 222 times
robynprivette wrote:I know how many entries are in there
Do you need a SUM to get a total of the values or a COUNT to get the number of rows?
User avatar
robynprivette
Forum Commoner
Posts: 46
Joined: Sun May 02, 2010 6:22 pm

Re: Adding all tables together?

Post by robynprivette »

yes i have phpmyadmin. i need the sum to get a total of all the values
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Adding all tables together?

Post by McInfo »

If you paste the queries from your script into phpMyAdmin, do you get the expected results?

Try the query I gave you before (repeated here). Do you get the expected result?

Code: Select all

SELECT
    (a.sum + b.sum + c.sum) AS total
FROM
    (SELECT SUM(code) AS sum FROM egg  ) AS a,
    (SELECT SUM(code) AS sum FROM hatch) AS b,
    (SELECT SUM(code) AS sum FROM er   ) AS c
User avatar
robynprivette
Forum Commoner
Posts: 46
Joined: Sun May 02, 2010 6:22 pm

Re: Adding all tables together?

Post by robynprivette »

No I get this 1e+19
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Adding all tables together?

Post by McInfo »

In phpMyAdmin,
  1. Click the Database: ... link at the top of the page.
  2. Click the Export tab.
  3. Uncheck everything except SQL and Structure (and None because it cannot be unchecked).
  4. Click the Go button.
  5. Copy-and-paste the CREATE TABLE statements in a reply.
I'm interested in the data types of the code fields.
Post Reply