Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Query between two tables

Posted on 2012-04-11
4
Medium Priority
?
341 Views
Last Modified: 2012-04-11
Greetings,
I am trying to use the following query to draw out articles from one table based on their date and a keyword and then sort through the description column in the article table looking for international cities to tie that article to.  For instance:

SELECT  Article.Date, Article.Title, Article.Link, City.City, City.Latitude, City.Longitude FROM Article INNER JOIN City
ON City.City Like '%' + Article.Description + '%' WHERE Article.IndexGUID='f50c528b-230f-4732-b3a9-138c7af039c2' AND
Article.Date BETWEEN '1/1/2012' AND '3/1/2012' AND Article.Title LIKE '%computer%' GROUP BY Article.Date, Article.Title,
Article.Link, City.City, City.Latitude, City.Longitude ORDER BY Article.Date DESC

For some reason this query doesn't work.  Any help would be extremely appreciated.  Thanks in advance.
0
Comment
Question by:MaxKroy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37834946
you are doing group by and no aggregate function is used in select statement.
please re-check what you are trying to achieve here...
0
 

Author Comment

by:MaxKroy
ID: 37835004
that doesn't help..thanks though??
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 2000 total points
ID: 37835053
Try this:-

SELECT  Article.Date, Article.Title, Article.Link, City.City, City.Latitude, City.Longitude FROM Article left outer JOIN City
ON City.City Like '%' + Article.Description + '%' WHERE Article.IndexGUID='f50c528b-230f-4732-b3a9-138c7af039c2' AND
Article.Date BETWEEN '1/1/2012' AND '3/1/2012' AND Article.Title LIKE '%computer%' 
ORDER BY Article.Date DESC

Open in new window

0
 

Author Closing Comment

by:MaxKroy
ID: 37835089
Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question