ifis Posted February 12, 2008 Share Posted February 12, 2008 Hey guys, I'm having trouble with joining two tables in a SELECT. Here is the code: $sql = "SELECT*FROM member JOIN blog"; $result=mysql_query($sql); while($row = mysql_fetch_array($result)){ echo" <tr> <td><h3>$row[firstName] $row[lastName]</h3></td>"; echo "<td>$row[Date]</td> <td>$row[Title]</td> </tr>"; } echo "</table>"; I get the error:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource. Any ideas? I'm sure it is something simple that I am just missing. Thanks. Link to comment https://forums.phpfreaks.com/topic/90774-simple-join-problem-in-a-select-statement/ Share on other sites More sharing options...
chantown Posted February 12, 2008 Share Posted February 12, 2008 JOIN ___ USING(id); Link to comment https://forums.phpfreaks.com/topic/90774-simple-join-problem-in-a-select-statement/#findComment-465343 Share on other sites More sharing options...
ifis Posted February 12, 2008 Author Share Posted February 12, 2008 Not totally sure what you mean: JOIN ___ USING(id); do you mean somthing like "SELECT*FROM member JOIN blog ON member.id=blog.id" ? Link to comment https://forums.phpfreaks.com/topic/90774-simple-join-problem-in-a-select-statement/#findComment-465354 Share on other sites More sharing options...
revraz Posted February 12, 2008 Share Posted February 12, 2008 A JOIN links two tables with some type of field, usually and ID field. Maybe you want a UNION? What is stored in the two tables and what are the field names. Which one is the field that links them. Link to comment https://forums.phpfreaks.com/topic/90774-simple-join-problem-in-a-select-statement/#findComment-465360 Share on other sites More sharing options...
ifis Posted February 13, 2008 Author Share Posted February 13, 2008 I figure it out. I was not capitalizing correctly. So it ended up working with: $sql = "SELECT*FROM blog JOIN Member ON blog.loginName = Member.loginName ORDER BY date DESC"; thanks for all the help Link to comment https://forums.phpfreaks.com/topic/90774-simple-join-problem-in-a-select-statement/#findComment-465570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.