944,058 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 485
  • MySQL RSS
Oct 13th, 2009
0

Inner Joins

Expand Post »
MySQL Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $host='localhost';
  4. $user='root';
  5. $pass='';
  6.  
  7. //establish database connection
  8. $conn=mysql_connect($host,$user,$pass) OR die('Unable to connect');
  9.  
  10. //SELECT database for USE
  11. mysql_select_db('acumenchain') OR die('Unable to select database!');
  12.  
  13.  
  14. $query2 = "SELECT tblclasslist.studentNo
  15. FROM acumenchain.tblclasslist
  16. JOIN acumenchain.tblregistration
  17. ON tblclasslist.studentNo = tblclasslist.studentNo";
  18.  
  19. $result = mysql_query($query2) OR die('Unable to execute Query' . mysql_error());
  20. $num = mysql_num_rows($result);
  21.  
  22.  
  23. //close connection
  24. mysql_close($conn);
  25.  
  26. ?>

database name : acumenchain
Under my tblclasslist is studentNo (primary key).
Under my tblregistration is studentNo (primary key) and pword
Under my tbllogin is studentNo (primary key) and pword.

Objectives:
  • I want that only students who are registered in the tblclasslist can register on tblregistration.
  • I want that only who are registered can log-in to my site using his/her studentNo and pword.
Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
theo19 is offline Offline
10 posts
since Nov 2008
Oct 14th, 2009
0
Re: Inner Joins
Try this:
php Syntax (Toggle Plain Text)
  1. $query2 = "SELECT tblclasslist.studentNo FROM acumenchain.tblclasslist JOIN acumenchain.tblregistration ON tblclasslist.studentNo = tblregistration.studentNo JOIN acumenchain.tbllogin ON tblclasslist.studentNo = tbllogin.studentNo AND tbllogin.studentNo = tblregistration.studentNo";
Does this give the desired result?
Reputation Points: 395
Solved Threads: 192
Veteran Poster
darkagn is offline Offline
1,136 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: password for phpmyadmin
Next Thread in MySQL Forum Timeline: newbie mysql join help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC