I am trying to run a query to return the customer first and last name only if the IP address they have used for a session is different.
for example:
Customer 1 makes Order on Session IP address: 192.168.12.1
Customer 1 makes Order on Session IP address: 192.168.12.2
Customer 2 makes Order on Session IP address: 192.168.12.3
Customer 2 makes Order on Session IP address: 192.168.12.3
Return Customer where IP address is not same (Customer 1)
However, I can’t work out how to specify the difference in the IP address.
What I currently have is:
Select Cust_First, Cust_Last
FROM customer
LEFT join Session
On customer.cust_ID = session.Cust_ID
LEFT join Order
On session.Ses_ID = order.Session_ID
Where Ses_IPAddress # Is different for the same customer?
I’ll detail the tables with the necessary fields:
Customer:
PK: Cust_ID
row: Cust_First
row: Cust_Last
Session:
PK: Ses_ID
FK: Cust_ID
Row: Ses_IPAddress
Order:
PK: Order_ID
FK Ses_ID
Actually the task is way easier than the way you are trying to complete it. Just select these customers from the ones that do fit your logic.