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 Quote Link to comment 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 " Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.