Solved

SQL Query with Subquery

Posted on 2012-03-21
3
247 Views
Last Modified: 2012-08-14
I'm having trouble getting this sql query to work:

SELECT Date, Title FROM (SELECT Date, Title FROM Article WHERE Title LIKE '%US%') WHERE Date BETWEEN '1/1/2012' AND '2/1/2012'

Please advise. Thanks in advance.
0
Comment
Question by:MaxKroy
3 Comments
 
LVL 21

Accepted Solution

by:
Dale Burrell earned 500 total points
ID: 37751119
SELECT Date, Title
FROM
(
  SELECT Date, Title
  FROM Article
  WHERE Title LIKE '%US%'
) X
WHERE Date BETWEEN '1/1/2012' AND '2/1/2012'

Open in new window

0
 

Author Closing Comment

by:MaxKroy
ID: 37751124
Awesome, thanks dale
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 37751924
just a  question, why do you need the subquery?  why not just use:

SELECT Date, Title
FROM Article
WHERE Title LIKE '%US%'
AND Date BETWEEN '1/1/2012' AND '2/1/2012'
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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.

820 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