Page 1 of 1

Query Question

Posted: Thu Aug 17, 2006 9:43 am
by psurrena
To preface, there are two tables, address and job. Address has "a_id" and is referenced in job.

In plain english I want the query both job and address according to the "j_id" but also pull the correct company info according to "a_id".

I know the current query is missing some of this, I'm not sure how to construct it.

Any help would be greatly appreciated.

-Pete

Code: Select all

<?php	
	include 'includes/connect.php';
	
	$j_id = $_GET['j_id'];
			
	$query   = "SELECT * FROM job, address WHERE j_id='$j_id'";
	$result  = mysql_query($query) or die('Error : ' . mysql_error());  
	$row     = mysql_fetch_array($result, MYSQL_ASSOC); 
	
	$status		      = $row['status'];
	$type	 	       = $row['type'];
	$jobname 	  = $row['jobname'];
	$jdescription     = $row['jdescription'];
	$jobid	 	       = $row['jobid'];
	$date     	       = $row['entry_date'];
	$jobid	 	       = $j_id . $jobid;
?>

Posted: Thu Aug 17, 2006 9:47 am
by feyd

Code: Select all

...
FROM `job`
INNER JOIN `address`
  ON( `job`.`a_id` = `address`.`a_id )
WHERE
  `j_id` = '$j_id'

Posted: Thu Aug 17, 2006 9:53 am
by psurrena
Perfect! Thank you.

Posted: Thu Aug 17, 2006 9:56 am
by Luke
your avatar Image

Posted: Thu Aug 17, 2006 9:57 am
by psurrena
Doesn't everyone love Action Jackson? :wink: