Results 1 to 6 of 6
Nov 3, 2012, 00:51 #1
Pulling data from identical tables
we are recruiting candidates for 3 projects.
project a , project b and project c
candidats are put on 3 tables for the projects they were hired
i want to list all the candidats from 3 tables on the screen. we have total 400 candidates.
i have the flowing query
$query="SELECT candidates_project_a.*, candidates_project_b.*, candidates_project_c.* From candidates_project_a, candidates_project_b, candidates_project_c
what could be wrong?
Nov 3, 2012, 01:36 #2
- Join Date
- Sep 2005
- Sydney, NSW, Australia
- 24 Post(s)
- 1 Thread(s)
When you join tables together like that every record in the first table is combined with every record in the second table and those entries are then combined with every record from the third table giving you potentially millions of results.
What you need to get the results you are after is to UNION the results of three SELECTs each of which gets the records from only one table.
Nov 3, 2012, 01:42 #3
Nov 3, 2012, 02:03 #4
Nov 3, 2012, 02:35 #5
- Join Date
- Aug 2008
- The Netherlands
- 136 Post(s)
- 2 Thread(s)
Even better would be to create a single projects table that describes all the projects and then a separate candidates table that points back to this projects table. That way you can query just the candidates table with a WHERE clause specifying which projects you want and it allows you application to scale easily. i.e., you don't need to create a table for a new project anymore.Rémon - Hosting Advisor
Minimal Bookmarks Tree
My Google Chrome extension: browsing bookmarks made easy
Nov 3, 2012, 02:52 #6