August 30th, 2012, 10:16 AM
Help :( group by multiple values in single column
group by multiple values in single column
I have 3 different columns and I want to sort each value in percentage like 100% to 1%
e.g. suppose 3 columns are country, visited cities, travelled by
i.e. suppose country is India, cities are mumbai, kolkata, chennai and travelled by bus, train, plane
So we have ids into the database separated by comma for cities and travelled by,
Now we have to sort maximum number of people first giving priority to country then travelled by and then visited cities and put them in ascending order
So please suggest me can we do with single MySQL query or we need to go for any searching and grouping algorithm.
We are seeking all to be done with minimum coding efforts, I tried all possible ways but coding approach was heavy, seeking non robust database tables and effective search query or algorithm.
Thanks in advance
August 30th, 2012, 01:14 PM
sounds like you have a mess on your hands -- "we have ids into the database separated by comma"
please do a SHOW CREATE TABLE for the table
August 31st, 2012, 02:22 AM
Actually we have 3 separate tables- country,cities and travelled by
in one table(user) we are adding these with 3 different fields
The user table is have columns - name. country, visited cities, travelled by
and a single row have values like "Mahesh", "1", "25,32,7","17,7,12"
Where country: 1-India
cities: 25-mumbai, 32-kolkata, 7-chennai
and travelled by: 17-bus, 7-train, 12-plane
August 31st, 2012, 04:18 AM
August 31st, 2012, 06:17 AM
this needs to be normalized
Originally Posted by MaheshCL
August 31st, 2012, 08:16 AM
How can I apply percentage logic on this normalized form of query, I am thinking about keeping normalized data in an array. Shall I completely depend on programming or I can fetch percentage wise data via sql query
August 31st, 2012, 08:30 AM
August 31st, 2012, 08:51 AM