[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL Query between two tables

Posted on 2012-04-11
4
Medium Priority
?
344 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
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

873 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