I need to retrieve a series of id number from a log table.
The log table has entries as follows:
log_id time event
1 2010-09-07 16:08:06 Quote sent to: customer_a [1176]
cust_a@email.com
2 2010-09-07 16:08:06 Quote sent to: customer_b [1320]
cust_b@email.com
The ids are in the square brackets and i need to retrieve a list of them (i know i should have designed my logs table better!)
I've come up with the following query:
select substr(`event`, locate('[', `event`)+1, locate(']', `event`) - (locate('[', `event`)+1)) as id from `logs` where substr(`event`,1,5) = 'Quote'
Which does work but seems a bit of a mess - i just wondered if there was a better solution?
any help/comments gratefully received
thanks
j