Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL-Server
Hello
I have a query in sql server 2008
 
SELECT  r.[Name] FROM [Center] c
INNER JOIN SwitchType s ON c.[ID] = s.[ID]
RIGHT JOIN [ReportType] r ON c.[ID]= r.[ID]
 

its work good . but I add condition to my query its doesn't work . for example
 
SELECT  r.[Name] FROM [Center] c
INNER JOIN SwitchType s ON c.[ID] = s.[ID]
RIGHT JOIN [ReportType] r ON c.[ID]= r.[ID]
where c.[Name] = 'a'
 
why ? pleas help me .
Posted 17-Nov-12 23:44pm
Edited 17-Nov-12 23:45pm
v2
Comments
OriginalGriff at 18-Nov-12 6:01am
   
What do you mean by "it doesn't work" - try to explain what teh problem is. Does it select data you didn't intend? Select no data? Or throw an exception?

1 solution

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

Solution 1

may be it doesnt find any result where your center table name column = a
i think you need to use like.
 
SELECT  r.[Name] FROM [Center] c
INNER JOIN SwitchType s ON c.[ID] = s.[ID]
RIGHT JOIN [ReportType] r ON c.[ID]= r.[ID]
where c.[Name] like 'a%'
 
see more http://www.w3schools.com/sql/sql_like.asp[^]
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 458
1 OriginalGriff 294
2 George Jonsson 258
3 CPallini 160
4 Shemeemsha RA 140
0 OriginalGriff 5,985
1 Sergey Alexandrovich Kryukov 5,341
2 CPallini 4,760
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 18 Nov 2012
Copyright © CodeProject, 1999-2014
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