[insert_php]
global $wpdb;
/* wpdb class should not be called directly.global $wpdb variable is an instantiation of the class already set up to talk to the WordPress database */
$result = $wpdb->get_results( “SELECT * FROM rc_test”); /*mulitple row results can be pulled from the database with get_results function and outputs an object which is stored in $result */
//echo “
"; print_r($result); echo "
“;
/* If you require you may print and view the contents of $result object */
echo “ID”.” “.”Name”.”
“;
foreach($result as $row)
{
echo $row->id.” “.$row->name.” “.”
“;
}
/* Print the contents of $result looping through each row returned in the result */
[/insert_php]
SELECT Staff.Name
FROM Staff JOIN Food ON Food.StaffID = Staff.ID
WHERE Food.Name IN (‘Eggs’, ‘Toast’)
AND Staff.Gender = ‘Male’
GROUP BY Staff.ID
HAVING COUNT(Food.ID) = 2