I have four tables:
- dbo.Projects (id, ProjectName, Areas, PaymentSystem, Districts.id, purpose.id, types.id, etc)
- dbo.Districts(id, DistrictsName)
- dbo.Purpose (id, PurposeName) - has residential & commercial
- dbo.Types (id, typName)
I want to select projects where DistrictsName='District1' and PurposeName = 'residential'
I tried this procedure :
alter PROCEDURE GetProjects
@districtName nvarchar(50),
@purposeName nvarchar(50)
as
SELECT
p.ID, p.ProjectName, p.Areas,
p.PaymentSystem, p.ReceivedDate,
p.PropertyClassification,
p.ProjectImage,
dis.DistrictName,
Pur.PurposeName
FROM
dbo.Projects AS p
LEFT JOIN
dbo.Districts dis ON p.DistrictID = dis.ID
LEFT JOIN
dbo.Purpose pur ON p.PurposeID = pur.ID
WHERE
(dis.DistrictName = @districtName)
AND (Pur.PurposeName = @purposeName)
exec GetProjects @districtName='District1', @purposeName='residential '
When I execute this procedure, it returns with null - no data is returned.
Note: database supported Arabic language
When I execute this query it returns the result I think no data returned because Arabic language
SELECT
p.ID, p.ProjectName, p.Areas,
p.PaymentSystem, p.ReceivedDate,
p.PropertyClassification,
p.ProjectImage,
dis.DistrictName,
Pur.PurposeName
FROM
dbo.Projects AS p
LEFT JOIN
dbo.Districts dis ON p.DistrictID = dis.ID
LEFT JOIN
dbo.Purpose pur ON p.PurposeID = pur.ID
WHERE
(dis.DistrictName = N'arabic value')
AND (Pur.PurposeName = N'arabic value')
...,@purposeName='residential'LEFT JOINtoINNER JOIN. TheWHEREclause turn them toINNER JOINany way....,@purposeName='residential'exec GetProjects @districtName=N'arabic value',@purposeName=N'arabic value'and see if you get result? The problem might be in the Unicode things.