Question : String extract in a query field

I have a query field with the following type of data in the field:

EMail: [email protected], Tel Office: 9856 0400, Tel Office: 9856 0427

I need to extra the value "9856 0400" to place into another expression in the query.

I need a string construct that looks for the first occurent of "Tel Office: " and then takes the next 9 characters (the telephone number).

How do I do this?


Thanks,

Garry

Answer : String extract in a query field

SELECT mid(myField, Instr(1, myField, "Tel Office: ")+12, 9) AS myPhoneNumber
FROM myTable

Please note
It's going to have a pain full and slow death if "Tel Office: " isn't in the field, so we could do this:

SELECT Iif(instr(1, myField, "Tel Office: "), mid(myField, Instr(1, myField, "Tel Office: ")+12, 9), "") AS myPhoneNumber
FROM myTable

Dave :^)
Random Solutions  
 
programming4us programming4us