我正在尝试运行查询以仅在客户用于会话的 IP 地址不同时才返回客户的名字和姓氏。
例如:
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)
但是,我不知道如何指定 IP 地址的差异。
我目前拥有的是:
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?
我将用必要的字段详细说明表格:
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