stubarny Posted March 20, 2007 Share Posted March 20, 2007 Hi everyone, I'm trying to query a recruitment website database to find the live jobs (from table "ads_live"), archived jobs (from table "ads_not_live") and payment transactions (from table "transactions") for an account's username (stored in $_SESSION[account_username]). $sql = "SELECT * FROM ads_live, ads_not_live, transactions WHERE ad_account_username = '$_SESSION[account_username]'"; The above code fails and i can only google information on seeing if columns in different tables equal each other, rather than a variable. Thanks for your help! Stu Link to comment https://forums.phpfreaks.com/topic/43556-querying-three-tables-at-once/ Share on other sites More sharing options...
suzzane2020 Posted March 20, 2007 Share Posted March 20, 2007 when queryin 3 table we need to check for common fields in the 3 tables. so ur where conditoin would be " where tb1.field=tb2.field and tb2.field=tb3.field " Link to comment https://forums.phpfreaks.com/topic/43556-querying-three-tables-at-once/#findComment-211531 Share on other sites More sharing options...
fenway Posted March 21, 2007 Share Posted March 21, 2007 Even better would be to use proper JOIN syntax and have these as ON conditions. Link to comment https://forums.phpfreaks.com/topic/43556-querying-three-tables-at-once/#findComment-212236 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.