richiejones24 Posted November 19, 2011 Share Posted November 19, 2011 I am trying to join these 2 tables below, but its not working, any ideas where i am going wrong?? <?php require("../include/mysqldb.php"); $con = mysql_connect("$dbhost","$dbuser","$dbpass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$dbame", $con); $result = "SELECT * Reg_Profile_public.pref, Search_profiles_up.search_small_image FROM Search_profiles_up INNER JOIN Reg_Profile_public ON Search_profiles_up.UIN=Reg_Profile_public.UIN WHERE UIN='803272125132009'"; while ($row = mysql_fetch_array($result)) { echo $row['search_small_image']; echo $row['pref']; } ?> Quote Link to comment Share on other sites More sharing options...
Fadion Posted November 20, 2011 Share Posted November 20, 2011 I don't know your table structure, but you have an error in your SELECT statement. It should be: SELECT * FROM table... or SELECT col1, col2 FROM table Also, you can use the AS keyword to give the table an alias, as in: search_profiles AS sp. You can even omit it, as in: search_profiles sp, but personally I recommend it as it makes the code more readable. I would write your query like below: SELECT reg.pref, search.search_small_image FROM search_profiles_up AS search INNER JOIN reg_profile_public AS reg USING (uin) WHERE uin='803272125132009'; 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.