Date: 12/13/05 (PHP Community) Keywords: mysql, sql I am not very experienced at writing queries that pull from several tables... $maillist = array(); $Link = mysql_connect ($Host, $User, $Password); $Query = "SELECT fb_user.emailAddress, fb_user.ustatus, passgo.aprivi, member_services.salesAlert FROM fb_user, passgo, member_services WHERE fb_user.ustatus='active' AND passgo.aprivi='m' AND member_services.salesAlert='y' "; $Result = mysql_db_query ($DBName, $Query, $Link); if (!$Result) { print("$Query Solution: $Query = "SELECT u.userID, u.emailAddress, ui.cats, p.aprivi, ms.salesAlert FROM fb_user AS u INNER JOIN passgo AS p ON u.userID = p.goID INNER JOIN member_services AS ms ON u.userID = ms.serviceID LEFT JOIN fb_user_interest AS ui ON u.userID = ui.userID WHERE u.ustatus='active' AND p.aprivi='m' AND ms.salesAlert='y'"; Source: http://www.livejournal.com/community/php/378930.html
|