I am fairly new to php and mysql and am having an issue with a query.
SELECT candidate_id.master_id, candidate_contact_details.first_name,
candidate_contact_details.last_name,
candidate_contact_details.home_phone FROM candidate_id,
candidate_contact_details, qualifications WHERE qualifications.active = 'yes';
The database only has 2 records across 5 tables but this is returning 12 results in both php and directly on the mysql console. I know I am doing something wrong but cannot figure it out.
you need to make the query consistent.
the query you have is the Cartesian product of all your tables which in most of the case doesn’t make much sense
here is something better (assuming that
master_idis the reference to a candidate instance):even better would be use
JOINand use alias for table name to make code more readable: