Msg#: 4405210 posted 2:30 pm on Jan 9, 2012 (gmt 0)
I'm totally new to SQL and my php is't fabulous but I'm doing my best to learn :)
My problem is this. For simplicity and my current problem we'll say I have three tables in my database; one called 'men' with the columns 'ID' and 'name', the second table is called 'women' and also has columns 'ID' and 'name', and the third table is a linking table called 'pairs' with columns 'ID', 'men_ID' and 'women_ID'.
I need to retrieve the data and list all the entries according to ID numbers.
Here is what I've tried to no avail;
$query = "SELECT pairs.ID, men.name, women.name"; $query.= " FROM women INNER JOIN (men INNER JOIN pairs ON men.ID = pairs.men_ID) ON women.ID = pairs.women_ID";
// We could add the following too to pick out a solo entry or other such WHERE condition but right now we want them all // $query .=" WHERE (pairs.ID=1)";
$result = mysql_query($query) or die(mysql_error());
echo "Pair - " . $personA_Name . " meets " . $personB_Name . "<BR>"; } while($row = mysql_fetch_array($result)); } My friend helped me with this bit of code by using MS Access to create the query with the appropriate JOINS but I just get a long list of 'Underfined Index' errors, 3 for each row pointing to the 3 lines in the 'do' statement?