Beste lezers,
Ik ben bezig om mijn OSC webshop wat uit te breiden maar loopt tegen een SQL opdracht aan, waar ik niet uit kom.
Ik wil informatie uit 3 tabellen halen :
TABLE_ADDRESS_BOOK
TABLE_CUSTOMER
TABLE_CUSTOMER_INFO
De tabellen (TABLE_ADDRESS_BOOK en TABLE_CUSTOMER)zijn gelinkt door de customer_id.
De tabellen (TABLE_CUSTOMER en TABLE_CUSTOMER_INFO)zijn gelinkt door resp. de customers_id en de customers_info_id, deze zijn ook gelijk in waarde.
De bestaande opdracht doet dit slechts uit de eerste 2 tabellen :
$customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customer_discount, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customer_discount, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'");
Echter wil ik ook nog de volgende velden uit de TABEL_CUSTOMERS_INFO halen :
customer_info_veld1
customer_info_veld2
customer_info_veld3
customer_info_veld4
Ik dacht dus aan iets als :
$customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customer_discount, c.customers_dob, c.customers_email_address, a.entry_company, ci.customers_info_veld1, ci.customers_info_veld2, ci.customers_info_veld3, ci.customers_info_veld4, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customer_discount, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a, " . TABLE_CUSTOMERS_INFO . " ci on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = ci.customers_info_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'");
Maar het mogeduidelijk zijn, dat dat dus niet werkt.
Fout melding :
1064 - You have an error in your SQL syntax near ' customers_info ci on c.customers_default_address_id = a.address_book_id where a' at line 1
select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customer_discount, c.customers_dob, c.customers_email_address, a.entry_company, ci.customers_info_veld1, ci.customers_info_veld2, ci.customers_info_veld3, ci.customers_info_veld4, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customer_discount, c.customers_default_address_id from customers c left join address_book a, customers_info ci on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = ci.customers_info_id and c.customers_id = '3'
Ik zie door de bomen het bos niet meer.
Is er iemand die er wel verstand van heeft, die mij wil helpen?
Alvast bedankt.
758 views