Welcome Guest, Not a member yet? Register   Sign In
using phpMyAdmin to create temp tables
#6

(This post was last modified: 08-30-2020, 07:50 AM by richb201.)

Thx php. While playing with this I broke the whole application and spent Sat trying to fix it. I now have a consultant looking at it. I am moving away from stored procedures due to not having a decent way to debug one. I think that using subqueries might work for me but am having trouble with that too!

SELECT risk, SUM(w2_wages) FROM employees WHERE (SELECT risk FROM titles WHERE employee_title=title)

Here I have a list of all the employees for a company with their w2_wages and their employee_title as columns. I have a second table called titles that has a column called title and another column call risk. What I want is to total the wages for each risk category, either low, med, or high. This is what i want to end up with.  Basically, the titles tables doesn't have any wage information in it. I am trying to total the wages in the employees table for each risk category.  title and employees_title are the indexes. 

risk              SUM(w2_wages)
low               2000
med             10000
high             90000

I typed this into phpMyAdmin and can run it but I don't get any result. What I get is: 

risk              SUM(w2_wages)
NULL          NULL

I know that some of the wages are NULL but how do I protect against that and why does only one row show?
proof that an old dog can learn new tricks
Reply


Messages In This Thread
RE: using phpMyAdmin to create temp tables - by richb201 - 08-30-2020, 06:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB