0

I'm attempting to adapt the following query so that in Concats the results without any duplicates.

SELECT `increment_id`
FROM `sales_order`
WHERE `remote_ip`
LIKE '123.123.123.123'

Based on this post, I have adapted the query to the following:

SELECT `remote_ip`, GROUP_CONCAT(DISTINCT `increment_id` SEPARATOR ', ')
FROM `sales_order`
GROUP BY `remote_ip`

However, I'm struggling to find a place to add LIKE '123.123.123.123' without causing an error.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Craig
  • 139
  • 1
  • 2
  • 12

1 Answers1

1

You simply need to add the WHERE condition after your FROM clause, to filter the data accordingly:

SELECT `remote_ip`, GROUP_CONCAT(DISTINCT `increment_id` SEPARATOR ', ')
FROM `sales_order`
WHERE `remote_ip` LIKE '123.123.123.123'
GROUP BY `remote_ip`
Madhur Bhaiya
  • 28,155
  • 10
  • 49
  • 57