473,657 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I get this query to work?

SELECT surgeries.*, animals.*
FROM surgeries INNER JOIN animals ON [surgeries].[id]=[animals].[id]
AND WHERE (([surgeries].[date_a]=Date()) Or
[surgeries].[date_b]=Date());

I'm trying to write a query that joins two table together, animals and
surgeries where surgeries.id = animals.id and only where the surgery
date was date_a or date_b.

I'm doing this in Microsoft Access 2000 and am tearing out my hair
trying to figure it out.

Thanks in advance for all your help.

Nov 13 '05 #1
96 5663
Karen Hill wrote:
SELECT surgeries.*, animals.*
FROM surgeries INNER JOIN animals ON [surgeries].[id]=[animals].[id]
AND WHERE (([surgeries].[date_a]=Date()) Or
I'm trying to write a query that joins two table together, animals and
surgeries where surgeries.id = animals.id and only where the surgery
date was date_a or date_b.

I'm doing this in Microsoft Access 2000 and am tearing out my hair
trying to figure it out.

Thanks in advance for all your help.

You you need some ddl to make this clear, but I'll take a stab at what I
think you want:
AND (([surgeries].[date_op]='2005-07-04') OR
([surgeries].[date_op]='2005-05-30')));
This is the standard sql technique. You'll have to adjust for Access's
method of substituting input parameters, I'm a db2 user myself.
Nov 13 '05 #2
Karen Hill wrote:
SELECT surgeries.*, animals.*
FROM surgeries INNER JOIN animals ON [surgeries].[id]=[animals].[id]
AND WHERE (([surgeries].[date_a]=Date()) Or
[surgeries].[date_b]=Date());

I'm trying to write a query that joins two table together, animals and
surgeries where surgeries.id = animals.id and only where the surgery
date was date_a or date_b.

I'm doing this in Microsoft Access 2000 and am tearing out my hair
trying to figure it out.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Not sure how a surgery equals an animal?! You sure you have your tables
set up correctly?

Your query has incorrect syntax - there is no AND before WHERE.

SELECT surgeries.*, animals.*
FROM surgeries INNER JOIN animals ON [surgeries].[id]=[animals].[id]
WHERE [surgeries].[date_a]=Date()
OR [surgeries].[date_b]=Date())

A good rule of thumb is to always use a column list in the SELECT
clause, not the ALL wildcard (*).

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQtHi7YechKq OuFEgEQIERQCg8m 9qdvyTO9s3YJ1NT UwpdK1jSwcAn0T8
dqa96HvXQCHAkJd ZkrQyHrFJ
=a9kM
-----END PGP SIGNATURE-----
Nov 13 '05 #3
"Karen Hill" <ka**********@y ahoo.com> wrote in
news:11******** **************@ g49g2000cwa.goo glegroups.com:
SELECT surgeries.*, animals.*
FROM surgeries INNER JOIN animals ON
[surgeries].[id]=[animals].[id] AND WHERE
(([surgeries].[date_a]=Date()) Or [surgeries].[date_b]=Date());

I'm trying to write a query that joins two table together, animals
and surgeries where surgeries.id = animals.id and only where the
surgery date was date_a or date_b.

I'm doing this in Microsoft Access 2000 and am tearing out my hair
trying to figure it out.


Is the ID field in the two tables the same data? That is, does the
animals table have its own Autonumber field with the exact same name
as the Autonumber field in the surgeries table? If so, you don't
want to use it to join the two tables, as, despite the fact that
you've unwisely given it the same name, it's not the same data. One
is the ID for a surgery, and the other is an ID for an animal.

I never use "ID" as a field name. I always use names in the form
AnimalID or SurgeryID. I also name my tables in the form tblAnimal
and tblSurgery (singular, not plural, since the entity represented
by each record is a single instance of whatever entity the table is
storing data about). Then I can figure out the name of the primary
key by taking the table name, lopping off the first three characters
and adding "ID" to it.

Anyway, you should be storing the AnimalID in the surgeries table,
and linking on that:

SELECT surgeries.*, animals.*
FROM surgeries INNER JOIN animals ON
surgeries.Anima lID=animals.Ani malID
WHERE ((surgeries.[date_a]=Date()) Or surgeries.[date_b]=Date());

Also note that there oughtn't be an AND before the word WHERE.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4
You are giving the worst possible advise to the Newbie.
I also name my tables in the form tblAnimal and tblSurgery (singular, not plural, since the entity represented by each record [sic] is a single instance of whatever entity the table is storing data about). <<
First of all, there are no records and fields in RDBMS; rows and
columns are totally different concepts. I agree that "the entity
represented by each record [sic] is a single instance.." but that has
nothing with naming the table that holds those entities. What is the
name of the set, not the entities? This is one reason why a table is
not a file. Sets are not sequential, are not a list of entities. Read
any book on Sets. Or data modeling. You are doing record processing
in your head and have not moved to a set oriented model.

ISO-11179 Standards tells us not to put silly prefixes like "tbl-"
that describe the physical storage into a data element name. Name each
data element for what it is; never for how it is used in one place, how
it is encoded, where it occurs, etc. A data element should have one and
only one name.
Then I can figure out the name of the primary key by taking the table name, lopping off the first three characters and adding "ID" to it. <<


Amazing how you do not have to refer to industry standards, or even do
even minimal research! Gee, what a waste of time it was to create VIN,
ISBN, UPC, etc. codes! Of course it has no data integrity, but boy it
was quick!

Since autoincrement numbers cannot be validated or verified in the data
model, you would NEVER use them in an RDBMS. They are exposed physical
locators, usually an attmept to mimic the record numbers from a file
model.

Nov 13 '05 #5
"--CELKO--" <jc*******@eart hlink.net> wrote in
news:11******** *************@z 14g2000cwz.goog legroups.com:
You are giving the worst possible advise to the Newbie.


Oh, shut up, Celko.

You definitely know your stuff, but you are vastly impractical in
your advice.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #6
On Wed, 13 Jul 2005 02:03:51 GMT, "David W. Fenton"
<dX********@bwa y.net.invalid> wrote:
"--CELKO--" <jc*******@eart hlink.net> wrote in
news:11******* **************@ z14g2000cwz.goo glegroups.com:
You are giving the worst possible advise to the Newbie.


Oh, shut up, Celko.

You definitely know your stuff, but you are vastly impractical in
your advice.

--

Hi
Its a good job Chris Date doesn't read this group.

Personally I do everything in code in stored procedures and use things
like mdiff as much as possible in my SQL. I'm just waiting for
everyone to update to the post-relational hierarchical model.

Just kidding!
David
Nov 13 '05 #7
So why are so many of my consulting jobs doing clean up work on RDBMS
projects done in the manner you described:) I guess when the auditors
show up or the data integrity is gone or the whole thing falls apart,
the owners are willing to be "vastly impractical" and follow good
practices and standards.

Nov 13 '05 #8
AK
>>So why are so many of my consulting jobs doing clean up work on RDBMS
projects done in the manner you described:
<<

I guess that's because the startups that try to do it perfect the first
time just don't make it to profitability. Only the ones that take
shortcuts to get things done quickly grow up and eventually can afford
Mr Celko's advice

Nov 13 '05 #9
On 13 Jul 2005 14:59:11 -0700, "AK" <AK************ @hotmail.COM>
wrote:
So why are so many of my consulting jobs doing clean up work on RDBMS
projects done in the manner you described:

I guess that's because the startups that try to do it perfect the first
time just don't make it to profitability. Only the ones that take
shortcuts to get things done quickly grow up and eventually can afford
Mr Celko's advice


Maybe, they would do better if they did it right in the first
place. Doing it right does not necessarily mean taking a long time
about it.

Sincerely,

Gene Wirchenko

Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1717
by: James | last post by:
Is there a prepackaged query.asp for IIS 5.0 and windows 2000? If so, where can I find a copy?
3
1943
by: Nick Truscott | last post by:
<? // scoreinput.php - input a match score when match selected from list ?> <html> <head> <basefont face="Verdana"> </head> <body>
2
2206
by: Tim Simmons | last post by:
I am stumped. I encoded the action = of my form using GET and I can't seem to get the property/value stuff from it using a JavaScript script I got from the web. I want to create a trivia game where the user gets 1 question at a time and it keeps scoring until the end and gives a summary and I want to do it only in JavaScript (no ASP, PHP, JSP, etc). I tried submitting the quiz page to itself using a query string to keep track of...
1
3082
by: Nicolae Fieraru | last post by:
Hi All, I want to find if there is a different way than the way I am working now. Lets say I have a table, tblCustomers containing address details. I want a report with all the customers from a specific state. In order to generate that, I create a form, I put a combobox with the states and a Command Button which opens a report. The report is based on a query, qryCustomersByState which has a parameter (State) taken from the Form.
13
5833
by: Sue | last post by:
I'm working on a database that keeps track of employees hired by a general contractor on a project by project basis. These employees are hired to work on a project and are then laid off either at the end of the work they were hired to do or at the end of the project. Any employee may be hired, laid off and rehired several times during the course of time. The tables I have and the critical fields to my question are: TblEmployee EmployeeID...
1
1695
by: Carl B Davis | last post by:
Help please!!! I am an intermediate access user that is getting my bottom kicked by what seems an easy problem to fix. I maintain an employee database at work. I have set up a query from two tables to generate a query displaying useful fields, but only for those whom appear on both tables. The names are formatted different so I chose to join them using the SSN. I set up the query and joined the SSN property but when I run the query, it...
19
59955
by: bdt513 | last post by:
I am trying to extract the values from a query using VBA. Specifically, I want to concatenate all the values of the "rosEmail" field from query "qselRosterEmailList" into one string (strEmails). I can get one record's result by using the DLookup fuction, of course, but I want to get every record's value. To do this, I believe I need to build a recordset, but I do not know how. I've read about doing it using DAO in Access 97, but I am...
9
18544
by: Mike Bridge | last post by:
I am using MS Access 2003, and I typed in a query in SQL view which was working fine. Now when I open it, it gives me the error "Join expression not supported". Apparently, Access "fixed" it for me. Unfortunately, I can't correct it because when I click "OK", the window disappears. I don't see any way to open the query directly in SQL view, and both the Design and Data views exit as soon as I close the error dialog. Is there any way...
4
3706
by: Macroman | last post by:
MS Access XP, running on Win XP, Processor 2.4Ghz , 512Mb RAM, 40Gb Hard drive Table 1 has 167,000 records and contains the following fields tblone_custID tblone_easting tblone_northing Table 2 has 423,000 records and contains the following fields tbltwo_custID
19
2245
by: so many sites so little time | last post by:
the table is head the colunm is called body <?php //show_site.php // This script retrieves blog entries from the database. // Address error handing. ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); // Connect and select.
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.