1
I own a field called emailMSG0
within a table in the database. This field contains various information. Is there any possibility in SQL I filter what I want to get inside this field emailMSG0
? Bring only some information.
If I do a normal select for example:
SELECT emailMSG0 FROM TABELA
Give me that back:
Prezado Cliente <b><br><br>Pedido: <b>4264136</b>, NF: <b>1448692</b> <br>Pedido: <b>4264138</b>, NF: <b>1448693</b> <br>Pedido: <b>4264140</b>, NF: <b>1448694</b> <br><br>Data: <b>2015-12-08 10:37:49</b> Hora: <b>2015-12-08 10:37:49</b><br><br>Link do comprovante: <br><br><img src='cid:1krrpu5mb4br3'/>
Is there any way to filter out what I want to appear ? Like I just want to get back the requests from this field.
It’s not really XML, I just wanted to take something specific of this field so I don’t have to mess with the structure of the database because I will use this information in a web application.
– KevinF
I don’t know your context, but even without looking I would bet a PS4 that going down this path will only make your work more difficult in the medium and long term.
– Oralista de Sistemas
That’s not xml, that’s html.
– Nelson Aguiar
I do not touch the bank only in the web application but to make the query I need to filter it there, and the easiest I believe I would treat in sql that makes the query.
– KevinF
I think you had a question similar to that yesterday http://answall.com/questions/129211/occult-informs%C3%A7%C3%B5es-do-bank-no-php And I believe that to extract certain snippets from the string you will have to deal with this in PHP, finding a logic to implement in some way
– tkmtts
And from what I understood, you want to take information of order number and invoice number, from a field where you keep the email message with all this data and some other information
– tkmtts
I tried to find in PHP but in SQL query I think it would be more effective, the work in php doubles to do this.
– KevinF
Face I believe that treating this in PHP would be less expensive for you, since in the query you would have to use a lot of locates and substrings to do this and would not have a stable result, I believe that in the application would be easier to treat this.
– Nelson Aguiar
You have substring_index too, but you don’t have a fixed number of orders in that field, do you? And even then it would still be costly.
– Nelson Aguiar
It is the numbers are not fixed, the right would be to create a column with requests one with the NF but I can not move the structure, I will have to find something in the application same. Is there any solution ?
– KevinF
Expensive one of the possible solutions would be you take the string that returned from the bank and give a explode('Orders:', $return); from the index 1 of the array you will already have only the order numbers and nfs, but this is only the first step ai you will have to better deal with it, but it is already a way
– Nelson Aguiar
I answered there, is more or less what has to be done with the return of the database
– Nelson Aguiar