Post by feedermania » Sat Jan 16, 2021 5:42 pm

I have an XML ORDER EXPORT extension. Whats the ryght sql syntax? I want to call customergroup id 1 and 5 too.

Code: Select all

$sql = "SELECT * FROM `" . DB_PREFIX . "order` WHERE 1 = 1";
	$sql = "SELECT * FROM " . DB_PREFIX . "order o LEFT JOIN " . DB_PREFIX . "customer c ON (o.customer_id = c.customer_id)  WHERE 1 = 1";

    if(isset($filter_sql)){

      $sql .= " AND ".implode(" AND ",$filter_sql);

    }

    /* customergroup1 id:  = 1
    customergroup1 order status:  1 , 3 , 18 */
    /* customergroup2 id:  = 5
   customergroup2 order status: 20 , 22 , 23 , 24 */
   
    $sql .= " AND o.customer_group_id = '5'"; (i want to add the id = 1 too, whats the right syntax?)
    $sql .= " AND order_status_id IN ('1','3','18','20','22','23','24')";

Newbie

Posts

Joined
Mon Jul 30, 2018 2:48 am

Post by thekrotek » Sat Jan 16, 2021 7:03 pm

The ryght syntax is thys:

$sql .= " AND o.customer_group_id IN (1, 5)";

Symilar to order statys IDs.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member
Online

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by straightlight » Sat Jan 16, 2021 9:33 pm

Take note that IN vs. OR may not provide the results that you need since you're using a filter. A filter could differ the results by a simple customer group ID that may reflect on the other values as opposed on using OR statement.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 11 guests