SQL statement using two tables
am 19.03.2007 19:15:01 von mwagoner
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
Re: SQL statement using two tables
am 19.03.2007 19:39:21 von reb01501
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 ( 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
--
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.
Re: SQL statement using two tables
am 20.03.2007 00:52:00 von Jon Paal
google:
sql join two tables
"Maximus" wrote in message news:1174328101.389009.234400@b75g2000hsg.googlegroups.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
>