如何使此查询起作用? [英] How do I get this query to work?

查看:79
本文介绍了如何使此查询起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT手术。*,动物。*

来自手术INNER JOIN动物ON [手术]。[id] = [动物]。[id]

和WHERE (([手术]。[date_a] =日期())或

[手术]。[date_b] =日期());


我'我正在尝试编写一个将两张桌子连接在一起的查询,动物和

外科手术,其中surgeries.id = animals.id并且只在手术中使用日期为_ b $ b日期为date_a或date_b 。


我正在使用Microsoft Access 2000进行此操作并且正在撕掉我的头发

试图解决这个问题。

先谢谢你的帮助。

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.

推荐答案

Karen Hill写道:
Karen Hill wrote:
选择手术。*,动物。*
从手术INNER JOIN动物ON [手术]。[id] = [动物]。[id]
和WHERE(([手术]。[date_a] =日期())或者

我正在尝试编写一个将两个表连接起来的动物和动物手术的查询,其中surgeries.id = anim als.id并且只在手术日期是date_a或date_b的地方。

我在Microsoft Access 2000中这样做并且正在撕毁我的头发
试图弄清楚它好的。

在此先感谢您的帮助。
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.



您需要一些ddl才能说清楚,但我会抓住什么我想b / b
想要:

AND(([手术]。[date_op] ='''2005-07-04'')或者

([surgeries]。[date_op] =''2005-05-30'')));

这是标准的sql技术。您将不得不调整Access的'

替换输入参数的方法,我是db2用户自己。


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.


Karen希尔写道:
Karen Hill wrote:
SELECT手术。*,动物。*
FROM手术INNER JOIN动物ON [手术]。[id] = [动物]。[id]
AND WHERE (([手术]。[date_a] = Date())或
[手术]。[date_b] = Date());

我正在尝试编写一个查询将两张桌子连在一起,动物和外科手术,其中surgeries.id = animals.id,只有在手术日期为date_a或date_b的地方。

我在做这个微软Access 2000和我正在撕毁我的头发
试图解决它。
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.




-----开始PGP签名消息-----

哈希:SHA1


不确定手术如何等于动物?!你确定你有你的桌子

设置正确吗?

您的查询语法不正确 - 在WHERE之前没有AND。


SELECT手术。*,动物。*

来自手术INNER JOIN动物ON [手术]。[id] = [动物]。[id]

在哪里[手术]。[date_a] =日期()

或[手术]。[date_b] =日期())


一个好的经验法则总是在SELECT

子句中使用列列表,而不是ALL通配符(*)。


-

MGFoster ::: mgf00< at> earthlink< decimal-point> net

奥克兰,加利福尼亚州(美国)


-----开始PGP SIGNATURE -----

版本: PGP个人隐私5.0

Charset:noconv


iQA / AwUBQtHi7YechKqOuFEgEQIERQCg8m9qdvyTO9s3YJ1NTUwpdK 1jSwcAn0T8

dqa96HvXQCHAkJdZkrQyHrFJ

= a9kM

----- END PGP SIGNATURE -----



-----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:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQtHi7YechKqOuFEgEQIERQCg8m9qdvyTO9s3YJ1NTUwpdK 1jSwcAn0T8
dqa96HvXQCHAkJdZkrQyHrFJ
=a9kM
-----END PGP SIGNATURE-----


" Karen Hill" < KA ********** @ yahoo.com>写在

新闻:11 ********************** @ g49g2000cwa.googlegr psps.com:
"Karen Hill" <ka**********@yahoo.com> wrote in
news:11**********************@g49g2000cwa.googlegr oups.com:
SELECT手术。*,动物。*
来自手术INNER JOIN动物ON
[手术]。[id] = [动物]。[id]和WHERE
(( [手术]。[date_a] = Date())或[手术]。[date_b] = Date());

我正在尝试编写一个将两个表连接在一起的查询,动物
和手术,其中surgeries.id = animals.id,只有
手术日期是date_a或date_b。

我在Microsoft Access 2000中这样做,我正在撕裂脱掉我的头发
想弄清楚。
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.




两个表中的ID字段是否是相同的数据?也就是说,

animals表是否有自己的Autonumber字段,其名称完全相同

作为手术表中的Autonumber字段?如果是这样的话,你不会想要用它来加入这两张桌子,因为尽管

你却不明智地给它起了同样的名字,这不是相同的数据。一个

是手术的ID,另一个是动物的ID。


我从不使用ID作为字段名称。我总是使用形式名称

AnimalID或SurgeryID。我还以tblAnimal

和tblSurgery的形式命名我的表格(单数,不是复数,因为每个记录所代表的实体
是表格所属的任何实体的单个实例

存储数据)。然后我可以通过获取表名来找出主要

键的名称,删掉前三个字符

并添加ID。无论如何,你应该将AnimalID存放在手术台上,

并链接到:


SELECT手术。*,动物。*

来自手术INNER JOIN动物ON

手术.AnimalID = animals.AnimalID

WHERE( (手术。[date_a] = Date())或手术。[date_b] = Date());


另请注意,WHERE之前不应该有AND 。


-

David W. Fenton http://www.bway.net/~dfenton

dfenton at bway dot net http://www.bway.net/~dfassoc


这篇关于如何使此查询起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆