2) Have you tried echoing the query to see exactly what is being passed to the RDBMS? That is, perhaps session_id() or $customer_id is not giving a valid value. Yes the values are all their. I am using MySQL so I guess I will have to go a different route. I'll have to run 2 queries which is what I wanted to avoid, but I guess there's no other way Thanks for the quick reply. ---> Jonathan -----Original Message----- From: Paul Burney [mailto:paul.lists@burney.ws] Sent: Monday, March 03, 2003 10:06 AM To: jvilla@isdesigndev.com; PHP Database List Subject: Re: Help with a query on 3/31/03 10:41 AM, Jonathan Villa at jvilla@isdesigndev.com appended the following bits to my mbox: > I want to pull data from 2 tables but using a primary key from one. > > Here is what I think it should look like. > > SELECT item_id, subtotal, quantity from shopping_cart WHERE order_id = > (SELECT order_id FROM orders WHERE session_id = session_id()) AND > customer_id = $customer_id; A few questions: 1) Are you sure your RDBMS supports sub-queries? Most do, but MySQL does not. 2) Have you tried echoing the query to see exactly what is being passed to the RDBMS? That is, perhaps session_id() or $customer_id is not giving a valid value. 3) Using the results of (2) above, have you input the query into another RDBMS client (i.e., command line version) to see what kind of errors are given. HTH. Sincerely, Paul Burney <http://paulburney.com/> <?php while ($self != "asleep") { $sheep_count++; } ?> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php