myyis
asked on
subquery or join?
Which has better performance?
1. SELECT * FROM CONTACTPHONE CE
LEFT JOIN CALLS CL ON SUBSTR(replace(replace(rep lace(repla ce(CE.NUMB ER,' ',''),'-',''),'(',''),')', ''), -10, 10)=SUBSTR(CL.NUMBER, -10, 10) AND CE.ORID=CL.ORID
2. SELECT * FROM CONTACTPHONE CE
LEFT JOIN CALLS CL ON SUBSTR(replace(replace(rep lace(repla ce(CE.NUMB ER,' ',''),'-',''),'(',''),')', ''), -10, 10)=(SELECT SUBSTR(CL.NUMBER, -10, 10) AND CE.ORID=CL.ORID
Thank you.
1. SELECT * FROM CONTACTPHONE CE
LEFT JOIN CALLS CL ON SUBSTR(replace(replace(rep
2. SELECT * FROM CONTACTPHONE CE
LEFT JOIN CALLS CL ON SUBSTR(replace(replace(rep
Thank you.
Can you explain what are you trying to achieve with some data?
ASKER
The table CONTACTPHONE is a list of customers with phone numbers.
Table CALLS is filled when an outbound call is received. We get the number calling but we don't know whose number it is.
So the problem is reaching the customer name using the numbers in CALLS table
Table CALLS is filled when an outbound call is received. We get the number calling but we don't know whose number it is.
So the problem is reaching the customer name using the numbers in CALLS table
ASKER
The 2nd alternative should be like this, I misedited, sorry for that
2. SELECT * FROM CONTACTPHONE
WHERE SUBSTR(replace(replace(rep lace(repla ce(NUMBER, ' ',''),'-',''),'(',''),')', ''), -10, 10)=(SELECT SUBSTR(NUMBER, -10, 10) FROM CALLS )
2. SELECT * FROM CONTACTPHONE
WHERE SUBSTR(replace(replace(rep
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
MySQL does have a computed column?
Argh! I thought I was looking through the SQL Server section, duh! Sorry! But the principle applies. Does MySQL not have computed columns?
Thanks for the points and sorry again about the MS vs MY SQL confusion. I assume you found out how to make a computed column in your MY SQL?