SQL statement using two tables

M

Maximus

I need some help with a SQL statement. I currently have which works:

strSQL = "SELECT * FROM mstJobs WHERE JobStatus = True"

I need to query against a second table but I am not sure of the
correct syntax of the statement for adding another table.. somthing
like this i would imagine... ????

strSQL = "SELECT * FROM mstJobs.pmdata WHERE JobStatus = True AND
WHERE WeekEnding IN tblSuperInput.pmdata = strThursday"

Any help or direction would be appreciated.

Thanks
 
B

Bob Barrows [MVP]

Maximus said:
I need some help with a SQL statement. I currently have which works:

strSQL = "SELECT * FROM mstJobs WHERE JobStatus = True"
Don't ask a database-related question without telling us what database
type and version you are using.

Given that "WHERE JobStatus = True " does not raise an error, I am going
to assume you are using a Jet (Access) database.
I need to query against a second table but I am not sure of the
correct syntax of the statement for adding another table.. somthing
like this i would imagine... ????

strSQL = "SELECT * FROM mstJobs.pmdata WHERE JobStatus = True AND
WHERE WeekEnding IN tblSuperInput.pmdata = strThursday"

No, probably not at all like this. However, we cannot answer this
question. We don't know which table has the WeekEnding field, or what
the datatype of that field is. Also, what table contains the strThursday
field? And is pmdata a table or field?

When asking how to create a query you should provide
1. the schemas for the tables involved in the query. By "schema", I mean
the names and datatypes of the fields involved in the query (if you have
a 50-field table, the quickest way to make us ignore your post is to
provide all 50 field names when you are only using 5 of them in your
query)
2. Some sample data in tabular format
3. The data that the query should retrieve from that sample data - again
in tabular format
4. A short explanation of why the data shown in step 3 should be
retrieved (<grin> and no, "because that's the data I want" will not
suffice)
5. If you've already made an unsuccessful attempt, show the sql you
attempted and show the results you obtained (again, in tabular format),
explaining why the results are incorrect - yes, I know this does not
apply to your current problem
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top