If we have a table T1
with a field named orders
have data type as Text
.
Such as the following:
user:1|number:2|expiry:9/2018
user:3|number:2|expiry:9/2018
user:1|number:3|expiry:1/2020
And i would like to SELECT
DISTINCT
based on number:
and expiry:
So expected output gonna be:
user:1|number:2|expiry:9/2018
user:1|number:3|expiry:1/2020
How to achieve that ?
You should consider to restructure your data and save these details in separate columns or in another table and in different columns to avoid such structural issues.
For now with existing structure you could use aggregation to get your expected data
select min(orders) orders
from table1
group by substring_index(orders,'|',-2)
http://rextester.com/GLT33046
Plz help me to write the script in ubuntu for tacking mysql backup,I have already written few line in the scriptsh file for tacking mysql dump and run this script from crontab, but it is not working
I have been struggling with google charts with MySQL data
I'm writing an ecommerce app and im writing a script to track the sales of items according to year/month