Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with SQL wording

Status
Not open for further replies.

Ngabay

MIS
May 16, 2003
25
US
I have 2 tables, Is this possible and if so how do I reword it. Tje 2 tables are dates and Activity

SELECT *
FROM Activity
WHERE actitivity. DATE BETWEEN dates.start AND dates.end


Thanks,
Nir
 

Hi Nit:

There has to be a connection or commonality between the two tables. For example, does the Activity table have a Date field that is associated with the Dates table? If so, then one can do an Inner Join:

Code:
SELECT *
FROM Activity INNER JOIN Dates
ON Activity.Date = Dates.Date
WHERE Activity.Date BETWEEN Dates.Start and Dates.End;
(This comment is in light that I do not know your table structures or your database structure.)

Cassie

 
Try This

Select * from Activity, Dates where activity.date BETWEEN dates.start and dates.end

Thought this will tack all the data from date onto the end so if all you want is the activity things you can specify those if you need to

Hope this helps

Brian
 
Cassie2002, that is only going to get the records where activity.date is equal to date.date

Which is not what this is wanting. But if that works could you explain how it does to me?

BRian
 
Oh an by the way, the would be like:

Select Activity.field1, Activity.field2, ... , Activity .Fieldx from Activity, Dates where activity.date between dates.start and dates.end

The problem you were having is that you have to mention every table you are going to use in the FROM clause to use the data fields later in the SQL Statement.

I think that Inner Join cassie was going for was something like this

Select * from Activity Inner Join Dates on ((activity.date >= dates.start) and (activity.date <= dates.end));

This works the same as the one I submitted earlier so you may still want to specify the Activity fields you need

Brian Coats
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top