duan4739 2012-07-18 17:54
浏览 52
已采纳

PHP + MySQL是否支持这种虚拟表连接?

I work with a proprietary server-side language that sits as a layer on top of a Oracle database. With this language, you can use dummy tables to take an existing record structure filled with data and run queries on that record structure joining to it as if it were a table.

Here's a simple example:

    //DECLARE THE RECORD STRUCTURE
    record data_out (
        1 prsnl [*]
            2 person_id = f8
            2 full_name = vc
            2 position = vc
            2 status = vc
            2 last_access_dt_tm = vc
            2 role [*]
                3 role_name = vc
                3 role_id = f8  
    ) with persistscript

    //QUERY PEOPLE
    select into "NL:"
    from person p
    where p.whatever_field = "QUALIFIER"
    detail

        a = a + 1
        stat = alterlist(data_out->prsnl, a)

        data_out->prsnl[a]->person_id = p.person_id
        data_out->prsnl[a]->full_name = p.name_full_formatted
        data_out->prsnl[a]->position = p.position

    with time=10

    //USE A DUMMY TABLE TO PULL IN MORE DATA FOR EACH PERSON
    select into "NL:"
    from (dumt d with seq = size(data_out->prsnl,5))
        ,rnd_role_def rrd
        ,rnd_r_assign_hx rah
    plan d
    join rah
        where rah.team_id = data_in->team_id
        and rah.prsnl_id = data_out->prsnl[d.seq]->person_id
        and rah.handoff_dt_tm > cnvtdatetime(curdate-90,curtime)
    join rrd
        where rrd.role_id = rah.role_id
    order by d.seq, rrd.role_name
    head d.seq
        i = 0
    head rrd.role_name
        i = i + 1
        stat = altlist(data_out->prsnl[d.seq]->role, i)

        data_out->prsnl[d.seq]->role[i]->role_id = rrd.role_id
        data_out->prsnl[d.seq]->role[i]->role_name = rrd.role_name

    with time=10

Does PHP+MySQL have anything like this? If so, could somehow point me to a link with more info or a how-to. Googling hasn't been turning up anything for me--probably searching for the wrong keywords.

  • 写回答

3条回答 默认 最新

  • dspv70887 2012-07-18 17:59
    关注

    Use temporary tables:

    CREATE TEMPORARY TABLE temp1
    

    A temporary table will persist through the current session. You can either define the fields of a temporary table through normal CREATE TABLE syntax:

    CREATE TEMPORARY TABLE temp1(
        `id` INT(11) NOT NULL AUTO_INCREMENT,
        `name` VARCHAR(50),
    )
    

    ... or you can create a temp table and allow query data to define the columns:

    CREATE TEMPORARY TABLE temp1;
    INSERT INTO temp1
      SELECT id, name FROM normal_table
    

    Documentation

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证