Hi
The below code is working fine with one problem that is shown many records where it suppose to show only one. (for example: if a user from UserInfo table has 10 ads into ads table where 5 of those ads has value similar to Query String result value, so he repeat the user 5 times where it suppose to appear once whatever he have ads where Wtag column.)
i make quick screen record explaining the issue hope that will be more clear to understand the issue, please have a look
https://www.youtube.com/watch?v=lh2GY2_whVM&feature=youtu.be
- SELECT DISTINCT UI.[UID]
- ,UI.[Country]
- ,UI.[State]
- ,UI.[City]
- ,UI.[Logo]
- ,UI.[Website]
- ,UI.[UsrType]
- ,SUBSTRING(UI.[CompDesc], 1, 60) AS CompDesc
- ,UI.[BizCateg]
- ,UI.[BizSubCateg]
- ,UI.[Twitter]
- ,UI.[GooglePlus]
- ,UI.[Facebook]
- ,UI.[CompNme]
- ,UI.[RegDate]
-
- ,AD.[Wtags]
- FROM UserInfo AS UI
- JOIN ads AS AD ON AD.[UID] = UI.[UID]
- WHERE UI.[Country] = @Location AND UI.[UsrType] = 'Business'
- AND CHARINDEX(@Wtag, AD.[Wtags])> 0 ORDER BY UI.[RegDate] DESC