Chris.P Posted May 16, 2007 Share Posted May 16, 2007 I have created a join between two tables that gets all of the contents from both tables into one. I now need to do this again but only list the details for a particular id that that matches the variable $bandid. I cant figure out how to go about this as I don't be able to put in ore than one WHERE statement? ??? <?php $bandid = $_GET["bandid"]; echo "<h1>Profile for: ".$bandid."</h1><br />"; include_once 'functions.php'; loginDetails(); $query = "SELECT users.id, users.bandname, users.bio, users.history, users.discography, images.path ". "FROM users, images ". "WHERE users.id = images.id"; Quote Link to comment https://forums.phpfreaks.com/topic/51640-solved-help-with-join/ Share on other sites More sharing options...
bubblegum.anarchy Posted May 16, 2007 Share Posted May 16, 2007 First, a question: Do you understand the following sentence? I cant figure out how to go about this as I don't be able to put in ore than one WHERE statement? And now the answer: SELECT user.id, user.bandname, user.bio, users.history, users.discography, images.path FROM users, images WHERE users.id = images.id AND users.bandid = $bandid or SELECT user.id, user.bandname, user.bio, users.history, users.discography, images.path FROM users INNER JOIN images ON users.id = images.id WHERE users.bandid = $bandid Quote Link to comment https://forums.phpfreaks.com/topic/51640-solved-help-with-join/#findComment-254397 Share on other sites More sharing options...
Chris.P Posted May 16, 2007 Author Share Posted May 16, 2007 First, a question: Do you understand the following sentence? I cant figure out how to go about this as I don't be able to put in ore than one WHERE statement? And now the answer: SELECT user.id, user.bandname, user.bio, users.history, users.discography, images.path FROM users, images WHERE users.id = images.id AND users.bandid = $bandid or SELECT user.id, user.bandname, user.bio, users.history, users.discography, images.path FROM users INNER JOIN images ON users.id = images.id WHERE users.bandid = $bandid Thanks, yes I do understand it although I could see why you may find it hard to understand due to the typos. Apologies for that I shall check before I post in the future. I did try the AND statement before you posted which did not work although I think I may have missed off the table name. The solution you suggested works fine, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/51640-solved-help-with-join/#findComment-254406 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.