【问题标题】:copy data from the three tables into a fourth table将三个表中的数据复制到第四个表中
【发布时间】:2016-05-27 07:56:21
【问题描述】:

试图创建一个活动注册站点,但由于将数据从多个表复制到另一个表而陷入困境。

我有三个表,其中包含名为用户、事件和票证的数据。

tbl 1 名为 user,具有以下字段:UserID、FName、LName

tbl 2 称为 event,具有以下字段:eventID、eventName、EventDescription

tbl 3 称为 ticket,具有以下字段:ticketID、ticketName、ticketDescription、eventID (来自表 2 的 eventID)

.

tbl 4 称为 registration,具有以下字段:

UserID、FName、FName、eventID、eventName、EventDescription、ticketID、ticketName、TicketDescription (来自登录用户的UserID、FName、FName)

.

当用户登录时,他会看到所有即将举行的活动,他可以选择一个,然后显示该特定活动的不同门票。

当他选择一张门票时,他会获得有关该特定门票 + 活动的更多信息。

如果用户单击注册按钮,则应运行一个查询,将数据从三个表复制到第四个表中,称为注册。

有人可以帮我吗?

问候,本尼

【问题讨论】:

    标签: php mysql


    【解决方案1】:

    我建议你使用这样的东西(假设你可以加入所有 3 个表):

    SELECT * INTO `registration` from (
      //SQL query that joins the first 3 tables and selects the col's u need.
    )
    

    【讨论】:

    • 不知道如何加入表格。
    • 与关系共享所有表列名称。
    【解决方案2】:

    试试:

    select * into newtable from
    ( 
    select * from table1
    union all
    select * from table2
    union all
    select * from table3
    ) A
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-01
      • 2019-08-01
      • 2018-03-23
      • 2013-01-30
      • 1970-01-01
      • 1970-01-01
      • 2018-11-20
      • 2020-12-18
      相关资源
      最近更新 更多