Click here to Skip to main content
16,004,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

The Int=1 ,N varchar=2,3
After concate this two the result is 1,2,3
How can i use the concate result in where condition.....?

This is my concate function
SQL
( SELECT CONCAT(Cities.FK_PrimaryLanguage_ID,',',Cities.FK_SecondaryLanguages_ID)
           FROM Cities  WHERE ID= 1)


the Results is 1,2,3
This is my stored procedure
SQL
ALTER proc [dbo].[Sp_GetMoviesWith_ReviewList]
(

@city int
)
as
begin 
select  m.ID AS id ,m.ReleaseDate AS rdate ,m.MovieName AS title
          
		    --,(  SELECT avg(Reviews.Rating)  FROM Reviews WHERE Reviews.FK_Movie_ID = m.ID) as rating
		    ,dbo.Movierating(m.ID) as rating 
			 --,re.Rating
            ,L.Language AS LANGUAGE
			,m.status AS isactive
			
			,m.MobileThumbnailImage AS thumbnail
			,( SELECT CASE WHEN COUNT(Trailers.ID)>0 THEN 'true' ELSE 'false' END FROM Trailers WHERE Trailers.FK_Movies_ID = m.ID) AS hastrailers
			,( SELECT CASE WHEN COUNT(Reviews.FK_Movie_ID)>0 THEN 'true' ELSE 'false' END FROM Reviews WHERE Reviews.FK_Movie_ID =  m.ID) AS hasreviews
			,m.Description AS description
			,m.cast AS casting
						
		  FROM Movies as m
		  INNER JOIN Languages L ON m.FK_Languages_ID = L.ID
	      --INNER JOIN Reviews re ON re.ID = m.ID
		  INNER JOIN Theatres ON Theatres.ID = m.ID	
		 
		  WHERE m.status = 1 AND
		    
		  m.FK_Languages_ID IN
		      ( SELECT CONCAT(Cities.FK_PrimaryLanguage_ID,',',Cities.FK_SecondaryLanguages_ID) 
			--FROM Cities  WHERE ID= @city)
Out put:
Conversion failed when converting the nvarchar value '2,3' to data type int.
Posted
Updated 29-Nov-13 0:54am
v2

1 solution

 
Share this answer
 
Comments
Gujula Ravindra Reddy 29-Nov-13 7:12am    
HIFK_PrimaryLanguage_ID =1 datatype is int
FK_SecondaryLanguages_ID=2,3 datatype is nvarchar
after concate those two the result is 1,2,3
when i write where condition total 1,2, 3 records are coming ...how can i write the condtion to come both records ....?please give me a solution....
Maciej Los 29-Nov-13 8:12am    
Have you read related article?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900