lofaifa Posted March 22, 2012 Share Posted March 22, 2012 I Basically never did it before , i tried to add those two together $sql1="SELECT * FROM questions WHERE post_num_reporters<>0 ORDER BY post_num_reporters DESC , post_date ASC"; $sql2="SELECT * FROM answers WHERE post_num_reporters<>0 ORDER BY post_num_reporters DESC , post_date ASC"; soo they have they same columns names required , i tried this : $sql="SELECT * FROM questions,answers WHERE post_num_reporters<>0 ORDER BY post_num_reporters DESC , post_date ASC"; and it didnt work , whats the solution ?? Quote Link to comment https://forums.phpfreaks.com/topic/259508-select-from-multiple-tables-error/ Share on other sites More sharing options...
Maq Posted March 22, 2012 Share Posted March 22, 2012 You should be joining these tables: http://dev.mysql.com/doc/refman/5.0/en/join.html Quote Link to comment https://forums.phpfreaks.com/topic/259508-select-from-multiple-tables-error/#findComment-1330281 Share on other sites More sharing options...
awjudd Posted March 23, 2012 Share Posted March 23, 2012 You will need to prefix your tables in the WHERE and ORDER BY clauses. That said, you are currently doing a CROSS JOIN between these two tables which I don't think that is what you want. As Maq said, you probably want to do a JOIN. ~awjudd Quote Link to comment https://forums.phpfreaks.com/topic/259508-select-from-multiple-tables-error/#findComment-1330508 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.