I'm quite new to SQL and I kind off hit the wall with this:
I have quite simple SQL query but I need to modify that that query to select only IP_ADDRESS
from IPs range 100.64.0.0 – 100.127.255.255
and 10.0.0.0 – 10.255.255.255
. I know that I need to use regexp for that but do not know how? Can You help me?
Original query:
SELECT
sal.IP_ADDRESS, sal.COUNTRY_CODE, sal.EVENT_ID, p.name, p.PARTNER_ID
FROM
EVENTS_USER.STREAM_ACCESS_LOGS sal, EVENTS_USER.STREAM_USERS su, EVENT_USER.PARTNERS p
WHERE
su.PARTNER_ID = p.PARTNER_ID
AND sal.SUCESS = 'Y'
AND sal.COUNTRY_CODE is null;
Could this regexp look like that?:
SELECT * FROM EVENTS_USER.STREAM_ACCESS_LOGS(
select regexp_replace(regexp_replace('100.64.0.0', '(\d+)', '00\1'), '0*(\d{3})', '\1') IP_ADDRESS from dual
UNION ALL
select regexp_replace(regexp_replace('100.127.255.255', '(\d+)', '00\1'), '0*(\d{3})', '\1') from dual
) ORDER BY IP_ADDRESS;