Hello,
I'm creating login system, which is based by batch number.
I know how to do this in 2 queries, but i think it's possible to get the same result from one query.
$sql = "SELECT `dep_id` FROM `deposits` WHERE `dep_batch` = ".$batch;
$result = mysql_query($sql) OR exit(mysql_error());
$row = mysql_fetch_assoc($result);
if ($row != NULL) {
$sql = "SELECT `inv_id` FROM `investments` WHERE `dep_id` = ".$row['dep_id'];
$result = mysql_query($sql) OR exit(mysql_error());
$row2 = mysql_fetch_assoc($result);
if ($row != NULL) {
$_SESSION['inv_id'] = $row2['inv_id'];
}
}
if (!isset($_SESSION['inv_id'])) exit('Invalid batch!');
In the others words, i want to get inv_id from table investments where dep_id is equal to dep_id from deposits where batch = $batch.
How to do this in one mysql query?
Thank's