Solved

SQL Query between two tables

Posted on 2012-04-11
4
323 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 500 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

732 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