0

Please help me in my problem I am searching this topic all over the internet and still i don't have the luck. to solve my problem.. .. ...

So this the situation, I have 3 table 1 is organization.tbl, 2 is candidates.tbl, and 3 is voters.tbl so if the voters register and select 1 of the organization it uses that id of organization. so If the admin create the candidates and insert the organization that the same voters have.

I already created a column that has relationship with organization.tbl, candidates.tbl, voters.tbl and the org_id of candidates.tbl and voters.tbl is unique

my question is How to create query in php. ? If the org_id of voters is equal to org_id of candidates.tbl ?

this is my sample query for displaying the candidates

$result = mysql_query("SELECT * FROM candidates INNER JOIN voters On voters.org_id = candidates.org_id  WHERE position='President' ");

and this is for the voters log in

    $login_query=mysql_query("SELECT * FROM voters INNER JOIN candidates On candidates.org_id = voters.org_id  
WHERE id_number='$id_number' and password='$password' and status='Unvoted'")or die(mysql_error());
AiX En
  • 31
  • 1
  • 8
  • You should take a look @ : http://stackoverflow.com/questions/5706437/whats-the-difference-between-inner-join-left-join-right-join-and-full-join – Alex Feb 10 '15 at 15:15
  • what type of join do you think ill use? – AiX En Feb 10 '15 at 15:19
  • ill use left join for the second query – Alex Feb 10 '15 at 15:22
  • please help me to solve my problem – AiX En Feb 10 '15 at 15:59
  • please include a simple of your database tables. – Alex Feb 10 '15 at 16:00
  • `$result = mysql_query("SELECT voters.voters_id, voters.org_id, candidates.candidates_id, candidates.org_id, candidates.firstname, candidates.lastname, candidates.img FROM candidates INNER JOIN voters On voters.org_id = candidates.org_id WHERE position='President' ");` i created quert like this and still i having hard time to display the candidates that equal to voters.org_id – AiX En Feb 10 '15 at 16:55

0 Answers0