472,119 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

SQL statement using two tables

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

Mar 19 '07 #1
2 3393
Maximus wrote:
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 (<grinand 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

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 19 '07 #2
google:

sql join two tables
"Maximus" <mw******@caldrywall.comwrote in message news:11**********************@b75g2000hsg.googlegr oups.com...
>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

Mar 19 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

35 posts views Thread by Thomas Matthews | last post: by
2 posts views Thread by Alanoly J. Andrews | last post: by
2 posts views Thread by pei_world | last post: by
8 posts views Thread by nano2k | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.