rrrhythm Posted February 25, 2007 Share Posted February 25, 2007 I have the two following DB queries: $article = tep_db_query("select newsdesk_article_name from " . TABLE_NEWSDESK_DESCRIPTION . " where newsdesk_id = '" . $HTTP_GET_VARS['newsdesk_id'] . "'"); $customer = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'"); i would like to combine these into a single query. could someone help me with the syntax? i haven't yet mastered joins, which is what i think i need. or is it even possible to do it in one go, since these are two unrelated tables? also, any comments on optimizing, in terms of DB queries and parse time? thanks rj Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted February 25, 2007 Share Posted February 25, 2007 You typically combine queries when you have info that is related and have a field to join on, eg suppose the news_article field has a customer id field, and you only want to show the customer name for that particular news article. However, in this instance I don't see what there is to combine, I think you need the 2 separate queries as they are really unrelated. KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
rrrhythm Posted February 26, 2007 Author Share Posted February 26, 2007 You typically combine queries when you have info that is related and have a field to join on, eg suppose the news_article field has a customer id field, and you only want to show the customer name for that particular news article.However, in this instance I don't see what there is to combine, I think you need the 2 separate queries as they are really unrelated. ok. thanks for the advice. that was basically what i had already come to. cheers, rj Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.