Click here to Skip to main content
15,917,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SELECT NM.[news_id],
NI.image_Path
,CONVERT(varchar(50), [news_date],106) as news_date
,NM.[news_head]
,NM.[short_news]
,NM.[news_descrip]
,NM.[news_prod]
,NM.[prodduct_id]
,NM.[country]
,NM.[countrycode]
,NM.[news_source]
,NM.[news_url]
,NM.[news_status]
,NM.[RowNo]
,NM.[UpdatedON],NM.ActionName FROM NewsMaster NM INNER JOIN news_images NI on NM. news_id = NI.news_id
where NM.Created_Date = convert(varchar(10), getdate(), 102)
order by NM.news_date desc

What I have tried:

Above is my Query When i Use where NM.Created_Date = convert(varchar(10), getdate(), 102) it not working it is not getting record but when i remove Inner Join and search then it get records so please help me how to Search
Posted
Updated 28-Jul-17 1:47am

Start by changing your DB design: never store date values as strings. The chances are - and without your data all we can do is guess - that the dates in your Created_Date column aren't all exactly what you think. And since a string comparison requires all characters to be identical, a trivial difference means no match.
 
Share this answer
 
If it works when you remove the INNER JOIN, then that means there are no related records in the joined table.

Try using a LEFT JOIN instead.

But, as Griff said in Solution #1, make sure you're not storing dates as strings. Use one of the Date and Time types[^] instead.
 
Share this answer
 
in second table
news_images NI
has no records that date, that's the reason behind it.

Why you are using join, in above query, you are not fetching data from second table.
 
Share this answer
 
Comments
CHill60 28-Jul-17 11:13am    
You've added nothing that had not already been said

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