How can get max value from following code, here is listing best ten tags
Select id, tag, visit from tab_quotes_tag order by visit DESC limit 10;
id_| tag___|visit
23 |nikson | 906
now should get best quote for each tag where Table quotes
ID | quotes | tagid | counter
1 |bla bla bla | 10,23,43 | 2323
2 |bla bla bla | 3,45...... | 341
3 |bla bla bla | 23,10,12| 5563
4 |bla bla bla | 1,4 ...... | 164
Select *, max(counter) from Quotes where tagid='23' or tagid like '%,23' or tagid like '%,23,%' or tagid like '23,%'