Here is what I am working with:
$query = "SELECT Products.Title, Product_Lines.pl_Title, Manufacturers.man_Title".
"FROM Products, Product_Lines, Manufacturers ".
"WHERE Products.pl_ID = Product_Lines.pl_ID AND Product_Lines.man_ID = Manufacturers.man_ID";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['Title']. " - ". $row['pl_Title']. " - ". $row['man_Title'];
echo "<br />";
}
I am getting this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near 'WHERE Products.pl_ID = Product_Lines.pl_ID AND
Product_Lines.man_ID = Manufactur' at line 1
I am unfamiliar with this method and t开发者_JS百科his error
SELECT Products.Title, Product_Lines.pl_Title, Manufacturers.man_Title
FROM Products INNER JOIN Product_Lines ON Products.pl_ID = Product_Lines.pl_ID INNER JOIN Manufacturers ON Product_Lines.man_ID = Manufacturers.man_ID
WILL DO
I don't see white space before your FROM clause. This is a possible cause for the error. Try:
$query = "SELECT Products.Title, Product_Lines.pl_Title, Manufacturers.man_Title".
" FROM Products, Product_Lines, Manufacturers ".
"WHERE Products.pl_ID = Product_Lines.pl_ID AND Product_Lines.man_ID = Manufacturers.man_ID";
Need To follow two things
- Foriegn Key
- Join
Search Join i.e [left join right join...]
In Inter u ll get anwser for ur question/..
精彩评论