select across multiple tables? 
Author Message
 select across multiple tables?
I am trying to figure out how to execute a query based on info in two
different tables.

I have to tables, uploads and jobs

uploads has a field ('date') in it that jobs does not.

I want to select a field in jobs ('job_id') when the date in uploads
equals what I specify. uploads has this same exact field ('job_id').
Is there a way I can do this with a standard query, or is a program
necessary to pull needed info?

Hope that made sense..

Thanks.
Andrew



Sat, 18 Sep 2004 11:57:04 GMT
 select across multiple tables?

Quote:
> I have to tables, uploads and jobs

> uploads has a field ('date') in it that jobs does not.

> I want to select a field in jobs ('job_id') when the date in uploads
> equals what I specify. uploads has this same exact field ('job_id').
> Is there a way I can do this with a standard query, or is a program
> necessary to pull needed info?

I think this sounds like a simple JOIN between two tables. So you
would have something like:

SELECT a.job_id FROM jobs AS a, uploads AS b WHERE a.job_id = b.job_id
AND b.date = 'XXXXX';

where 'XXXXX' is the date you want. Also, if there are other fields
which are common to the 2 tables, you'll have to add them to the join
(e.g. WHERE a.field1 = b.field1 AND a.field2 = b.field2)

However, I'm not quite clear as to why you need to go to 2 tables if
you just want job_id and it is already in a table with the date field.
Maybe there's more to the query that I'm missing?

-Tony



Sun, 19 Sep 2004 05:49:12 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. Selecting across Multiple Tables

2. Select stmt across multiple databases

3. Full-text search across multiple tables

4. timestamp update field across multiple tables

5. SQL: using UPDATE across multiple tables

6. Full Text Search across multiple tables at once?

7. Unique System ID's across multiple tables

8. Full Text Searching Across Multiple Tables

9. Problems with views on tables across multiple databases

10. Problem with SQL Sum across multiple tables

11. Spreading a table across multiple nodes??

12. RB Alter table across multiple ranged data segments


 
Powered by phpBB® Forum Software