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 UserId=@UserId) \
								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 />";
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *