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')";

New member

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

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.

Dedication and passion goes to those who are able to push and merge a project.

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: Nordikota, Semrush [Bot] and 142 guests