Getting results from using 2 tables

Reply

Join Date: Nov 2008
Posts: 20
Reputation: stevehart808 is an unknown quantity at this point 
Solved Threads: 0
stevehart808 stevehart808 is offline Offline
Newbie Poster

Getting results from using 2 tables

 
0
  #1
Dec 9th, 2008
Hi can someone shed some light on this problem I'm having please?

2 tables

SHOWS_ARCHIVE (TABLE 1)

ID
SHOW_ID
AUTHOR

SHOWS (TABLE 2)

ID

When the member logs in they are a loud to see their shows because of the $author permissions;

  1.  
  2. if ($_SESSION['MEMBER_PERM'] == "2")
  3. {
  4. $author = $_SESSION['MEMBER_ID'];
  5.  
  6. $sql = mysql_query("SELECT * FROM show_archive WHERE author = $author");
  7. }

but I want to do is see the results using the SHOWS table ID as well. ie


if ($_SESSION['MEMBER_PERM'] == "2")
					{
$author = $_SESSION['MEMBER_ID'];

$sql = mysql_query("SELECT * FROM show_archive WHERE author = $author AND show_id = `shows` id");
					}
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 11
Reputation: indianrock9 is an unknown quantity at this point 
Solved Threads: 0
indianrock9 indianrock9 is offline Offline
Newbie Poster

Re: Getting results from using 2 tables

 
0
  #2
Dec 10th, 2008
Hi,
Try the following:

  1. if ($_SESSION['MEMBER_PERM'] == "2")
  2. {
  3. $author = $_SESSION['MEMBER_ID'];
  4.  
  5. $sql = mysql_query("SELECT *, * FROM show_archive, shows WHERE author = $author AND show_id = `shows` id");
  6. }

That should help you retrieve data from 2 tables at the same time. Let us know how it works.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 20
Reputation: stevehart808 is an unknown quantity at this point 
Solved Threads: 0
stevehart808 stevehart808 is offline Offline
Newbie Poster

Re: Getting results from using 2 tables

 
0
  #3
Dec 10th, 2008
Thanks but getting an error from that code.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 20
Reputation: stevehart808 is an unknown quantity at this point 
Solved Threads: 0
stevehart808 stevehart808 is offline Offline
Newbie Poster

Re: Getting results from using 2 tables

 
0
  #4
Dec 10th, 2008
Found the solution!

  1. SELECT * FROM show_archive, shows WHERE show_archive.show_id = shows.id
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for MySQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC