BarneyJoe Posted November 15, 2007 Share Posted November 15, 2007 Hope someone can help with this, as I'm still a bit new to this. Basically have one table Orders, and another OrderDetails. Have a page that lists Orders (simply based on the Orders table), and the user can click through to view the OrderDetails using the code : <a href="orderdetails.php?ID=<?php echo $row_rsOrders['OrderID']; ?>"><?php echo $row_rsOrders['VendorTxCode']; ?></a> Which works fine. However, I want to show on the Details page a couple of fields from the Orders Table - ie OrderTotal and VendorTxCode. My query at the moment looks like : SELECT * FROM Orders, OrderDetails WHERE Orders.OrderID = OrderDetails.DetailOrderID But think I need to use a JOIN (INNER) so that it knows which record to use based on the current OrderID, as the above is showing the values from the first record in the Orders table. If anyone can help out with the syntax, that would be much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/77539-help-with-query-syntax/ Share on other sites More sharing options...
pocobueno1388 Posted November 15, 2007 Share Posted November 15, 2007 You just need to add the orderID to your WHERE clause. SELECT * FROM Orders, OrderDetails WHERE Orders.OrderID = OrderDetails.DetailOrderID AND Orders.OrderID = '$OrderID' See if that does what you want. Quote Link to comment https://forums.phpfreaks.com/topic/77539-help-with-query-syntax/#findComment-392494 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.