难以查询 [英] difficult query

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

问题描述

大家好,


我有包含与会者的活动(活动有很多与会者)。

与会者表会告知用户是否参加活动。我想要建立一个查询,将所有不同的事件返回给用户

以及他是否会参加活动(或者还没有填写) )


返回的结果可能是这样的:


event.id与会者.user_id参与者。现场

1 1 0

2 1

3 1 1


请注意,如果用户没有'参与者,则可以为null还没有

告诉他是否会参加活动。


可以这样做吗?


谢谢

Stijn

Hi all,

I have events containing attendees (events has many attendees). The
attendee table tells whether a user will attend the event or not. I
want to build a query that returns all the different events to a user
and if he will attend the event or not (or hasn''t filled it in yet)

the returned result could be something like:

event.id attendees.user_id attendee.present
1 1 0
2 1
3 1 1

Please note that attendee.present can be null if the user didn''t yet
tell if he would come to the event.

Can this be done?

thanks
Stijn

推荐答案

" Tarscher" < ta ****** @ gmail.com写信息

新闻:b9 ************************ ********** @ i29g2000 prf.googlegroups.com ...
"Tarscher" <ta******@gmail.comwrote in message
news:b9**********************************@i29g2000 prf.googlegroups.com...

大家好,


我有包含与会者的活动(活动有很多与会者)。

与会者表会告知用户是否参加活动。我想要建立一个查询,将所有不同的事件返回给用户

以及他是否会参加活动(或者还没有填写) )


返回的结果可能是这样的:


event.id与会者.user_id参与者。现场

1 1 0

2 1

3 1 1


请注意,如果用户没有'参与者,则可以为null还没有

告诉他是否会参加活动。


可以这样做吗?


谢谢

Stijn
Hi all,

I have events containing attendees (events has many attendees). The
attendee table tells whether a user will attend the event or not. I
want to build a query that returns all the different events to a user
and if he will attend the event or not (or hasn''t filled it in yet)

the returned result could be something like:

event.id attendees.user_id attendee.present
1 1 0
2 1
3 1 1

Please note that attendee.present can be null if the user didn''t yet
tell if he would come to the event.

Can this be done?

thanks
Stijn



SELECT * FROM Tablename WHERE user_id =''TargetId''

以上将全部返回用户ID的字段。


SELECT FROM FROM Tablename WHERE user_id =''TargetId''

以上将返回所有present对于一个用户ID。


但是,我想还有另外一张表包含了

人的名字?

HTH

Vince

SELECT * FROM Tablename WHERE user_id = ''TargetId''
The above will return all fields for a user id.

SELECT present FROM Tablename WHERE user_id = ''TargetId''
The above will return all "present" for a user id.

However, I imagine there is another table that contains the names of the
persons?
HTH
Vince


12月21日,08:43,Tarscher< tarsc ... @ gmail.comwrote:
On 21 Dec, 08:43, Tarscher <tarsc...@gmail.comwrote:

大家好,


我有包含与会者的活动(活动有很多与会者)。

与会者表会告知用户是否参加活动。我想要建立一个查询,将所有不同的事件返回给用户

以及他是否会参加活动(或者还没有填写) )


返回的结果可能是这样的:


event.id与会者.user_id参与者。现场

1 1 0

2 1

3 1 1


请注意,如果用户没有'参与者,则可以为null还没有

告诉他是否会参加活动。


可以这样做吗?


谢谢

Stijn
Hi all,

I have events containing attendees (events has many attendees). The
attendee table tells whether a user will attend the event or not. I
want to build a query that returns all the different events to a user
and if he will attend the event or not (or hasn''t filled it in yet)

the returned result could be something like:

event.id attendees.user_id attendee.present
1 1 0
2 1
3 1 1

Please note that attendee.present can be null if the user didn''t yet
tell if he would come to the event.

Can this be done?

thanks
Stijn



这与php有什么关系?


你会更好在数据库组中询问这个问题。


但是有些问题:

如果用户正在查询数据库以查找他是否会参加

事件,为什么他自己的ID需要出现在输出中?

H.参与者的身份是否会在

第一名的事件中进入表格?

And this has what to do with php?

You would be better to ask this in a database group.

However some questions:
If a user is querying the database to find if he will be attending the
event, why does his own ID need to be present in the output?
How does the attendee''s id get into the table against an event in the
first place?


在21月12日,11:13 ,Paralytic上尉< paul_laut ... @ yahoo.comwrote:
On 21 dec, 11:13, Captain Paralytic <paul_laut...@yahoo.comwrote:

12月21日,08:43,Tarscher< tarsc ... @ gmail.comwrote:
On 21 Dec, 08:43,Tarscher<tarsc...@gmail.comwrote:

大家好,
Hi all,


我有包含与会者的活动(活动有很多与会者)。

与会者表会告知用户是否参加活动。我想要建立一个查询,将所有不同的事件返回给用户

以及他是否会参加活动(或者还没有填写) )
I have events containing attendees (events has many attendees). The
attendee table tells whether a user will attend the event or not. I
want to build a query that returns all the different events to a user
and if he will attend the event or not (or hasn''t filled it in yet)


返回的结果可能类似于:
the returned result could be something like:


event .id与会者.user_id与会者。现身

1 1 0

2 1

3 1 1
event.id attendees.user_id attendee.present
1 1 0
2 1
3 1 1


请注意,如果用户还没有确定他是否参加活动,则参与者可以为空。
Please note that attendee.present can be null if the user didn''t yet
tell if he would come to the event.


可以这样做吗?
Can this be done?


thanks

Stijn
thanks
Stijn



这有什么用php做什么?


你最好在数据库组中问这个。


但有些问题:

如果用户正在查询数据库以查明他是否将参加

事件,为什么他自己的ID需要出现在输出中?

如何参与者的身份是否会在第一名的

事件中进入桌面?


And this has what to do with php?

You would be better to ask this in a database group.

However some questions:
If a user is querying the database to find if he will be attending the
event, why does his own ID need to be present in the output?
How does the attendee''s id get into the table against an event in the
first place?



我确实不需要user_id,因为它存储在会话中。它只是为了澄清查询需要返回1个用户。


通过会话存储在会话中的user_id。


问候

I indeed don''t need the user_id since it is stored in the session. It
was just to clarify that the query need to return 1 user.

Via the session the user_id stored in the session.

Regards


这篇关于难以查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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