This is PHP4 Code!

Using IN Within A Normal SELECT Query

You can select from within another tables results really easily like this:


	SqlCommand1->CommandText = "SELECT ProjectId \
								FROM tblMyTable1 \
								WHERE ProjectIsActive='TRUE' AND ProjectId IN (SELECT ProjectId FROM tblMyTable2 WHERE ProjectUsersAll='TRUE' OR [email protected]) \
								ORDER BY ProjectStartDate DESC";

Simple Find Name From Another Table By Matching An ID Between The Tables


$sql = "SELECT table1.name, table2.member_id FROM table1, table2 WHERE table2.member_id = $member_id AND  table1.common_value = table2.common_value ORDER BY table1.name ASC";

$result = @mysql_query($sql);
$names_list = '';

while ($result = @mysql_fetch_array($result))
{
	$names_list .= $result['name'] . "<br />";
}
UK Electronic Designer
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published.