I need to run a query that would pull information from a field that has 2 types of data .
Field is address and has 123 avenue as data and bb@yahoo.com.
I need to
Based on this question and your duplicate question, I understand your table has a field which includes both the street address and email address and you want to split those into separate fields.
So your table includes this ...
YourField
------------------------------
1234 ave willie haha@yahoo.com
123 avenue bb@yahoo.com
And you want this ...
YourField street_address email_address
------------------------------ --------------- --------------
1234 ave willie haha@yahoo.com 1234 ave willie haha@yahoo.com
123 avenue bb@yahoo.com 123 avenue bb@yahoo.com
If that is correct, you can use the InstrRev()
function to determine the position of the last space in YourField
. Everything before the last space is the street address; everything after is the email address.
SELECT
y.YourField,
Left(y.YourField, InstrRev(y.YourField, ' ') -1) AS street_address,
Mid(y.YourField, InstrRev(y.YourField, ' ') +1) AS email_address
FROM YourTable AS y;
You may need to add a WHERE
clause to ensure the query only tries to evaluate rows which include your expected YourField
value patterns.