Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MySQL
Hi all
SELECT
GROUP_CONCAT(LT.TAG_TEXT) AS TAGS
FROM M_OBJECT_TAG_MAPPING MOTM
INNER JOIN LK_TAG LT ON MOTM.FK_TAG_ID = LT.PK_ID
WHERE MOTM.OBJECT_TYPE= 1 AND MOTM.IS_ACTIVE = 1
GROUP BY MOTM.FK_OBJECT_ID HAVING (TAGS LIKE '%US%')
This is showing result
US,SharePoint,Avenger
Australia,Sambalpur
Usa,Flex,Asp.Net,Uk
Australia,US
but i want the result should be
Australia,US
US,SharePoint,Avenger
 
This is showing result having 'us' in them actually i want only US present in the tag.
 
Please help so that i will get the second result
 
Thanks in advance
Posted 12-Jul-12 4:36am
Mac123341.1K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Consider different 3 cases.
First US at first: Here use 'US,%'
Second US at middle: Here use '%,US,%'
Finally US at last: Here use '%,US'
 
Thus change your Having clause as
HAVING (TAGS LIKE 'US,%' OR TAGS LIKE '%,US,%' OR TAGS LIKE '%,US')
 
Hope this will help Smile | :)
  Permalink  
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 645
1 Maciej Los 225
2 Richard Deeming 160
3 Suvendu Shekhar Giri 159
4 Abhinav S 151
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 9,135
2 Peter Leow 5,042
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,581


Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 12 Jul 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100