Link to home
Start Free TrialLog in
Avatar of v s
v s

asked on

what will be mysql query to display result as i required ?? ( counting records and display count for each category)

There are four Categories of employee
DRDS
DRTC
Admin
Allied

Each Category has certain Posts

there are three tables
Category master (category will be selected from here) [CategoryId]
designationmaster [DesignationId] [Category]
employee master [Designation]

CategoryId = Category
 DesignationId = Designation

i want to display data as per category selected from dropdown menu
for example i have selected DRDS
Under DRDS following are post like  Sc. B   Sc. C     Sc .D  Sc .E  etc

i want to display number of emloyees in every post of selected category


For example if I select DRDS Output should be like this
  HELD is number of employees of that post

RANK         HELD
Sc. H           01
Sc. G           07
Sc. F           05
Sc. E           02
Sc .D          10
Sc. C          15
Sc .B          07

similarly if i select DRTC  Output should be like this

RANK         HELD
TO D           03
TO C           33
TO B           35
TO A           29

Screenshots of tables are attached.


what will be the mysql query for this ??
how to fetch data from this query and display its count for every post of certain category
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of v s
v s

ASKER

@Julian Hansen
 whats wrong with this query.. its not working

"SELECT COUNT(*) AS held , d.DesignationDescription from employeemaster e LEFT JOIN  designationmaster d ON
                 d.DesignationId= e.Designation WHERE d.Category = ".$Category."GROUP BY e.Designation";
Not working is a very broad term
- It gives an error: In which case which error
- It does not return the right results: What results does it return
Avatar of v s

ASKER

no error
 but not returning anything
Avatar of v s

ASKER

Ok sir ... Its done by replacing Designation by DesignationDescription

thank you for your help :)
You are welcome.