MySQL - Check if column value (IP) appears in multiple references (orders) -
this table structure: (it's log)
columns
order id, ip, text, timestamp
i have data this:
orderref1 | 192.168.0.1 | text order | timestamp orderref1 | 192.168.0.1 | text order | timestamp orderref2 | 192.168.0.2 | text order | timestamp orderref3 | 192.168.0.3 | text order | timestamp orderref5 | 192.168.0.1 | text order | timestamp orderref3 | 192.168.0.3 | text order | timestamp orderref4 | 192.168.0.4 | text order | timestamp orderref2 | 192.168.0.2 | text order | timestamp
as can see data above, 1 ip appears in 2 orderrefs.
i need query shows me ip's have appeared in multiple orderid's , orderid's reference.
so results ideally send out this:
orderref1 | orderref5 | 192.168.0.1
as ip appearing in multiple orderref's result
this should trick. show id's , ip's of every ip has more 1 different id's
select group_concat(order_id), ip mytable group ip having count(distinct order_id)>1
Comments
Post a Comment