Forum Moderators: open

Message Too Old, No Replies

Help with mySQL statement and 3 tables

         

mattyb515

3:42 pm on May 15, 2006 (gmt 0)

10+ Year Member



Okay so here's what I've got:

$select = "SELECT a.orders_id, a.customers_name, a.customers_street_address, a.customers_street_address_2, a.customers_city,
a.customers_postcode, a.customers_state, a.customers_country, a.customers_telephone, a.customers_email_address,
b.products_model, c.value FROM orders a LEFT JOIN orders_products b ON a.orders_id = b.orders_id LEFT JOIN orders_total c ON b.orders_id = c.orders_id
WHERE(
EXTRACT(MONTH FROM a.date_purchased) = EXTRACT(MONTH FROM CURDATE())
AND
DAYOFMONTH(a.date_purchased) = (DAYOFMONTH(CURDATE()) - 1)
)";

Now with this ginormous statement I also limit the c.value selection based on another field in the table. That being
c.title="total:" I have no idea how to go about doing this. I'm attempting to pull data from a db that's used by our shopping cart. And the shopping cart stores all totals that relate to a particular order in one table. I hope this isn't too confusing.

FourDegreez

4:03 pm on May 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think what you want to do is add

AND c.title="total:"

after

ON b.orders_id = c.orders_id

before the WHERE clause

mattyb515

4:40 pm on May 15, 2006 (gmt 0)

10+ Year Member



No dice on that one. I get the good old Warning: mysql_num_fields(): supp blahblahblah error. I also tried it with single and double quotes and still got the error.

mattyb515

4:49 pm on May 15, 2006 (gmt 0)

10+ Year Member



sorry fourdegreez i had a typo. you were correct it worked. thanx a million