dongluzhi5208 2017-07-20 06:24
浏览 69
已采纳

在一个查询中获取5个表数据...没有连接...没有关系

I have 5 tables or more for a logs.

  1. tbl_product_log
  2. tbl_user_log
  3. tbl_customer_log
  4. tbl_vendor_log
  5. tbl_quotations_logs

They have no relation with each other. But they have same hierarchy of columns.

  1. logid
  2. logdetails
  3. logdatetime

Every time when, there is something happened in these tables (e.g. 'insert','delete',update) a record inserted in relative table for a log.

Now I want to show all logs in one page. There are 6 tabs in it.

  1. All Logs
  2. Product Logs
  3. User Logs
  4. Customer Logs
  5. Vendor Logs
  6. Quotation Logs

Like this

enter image description here

In Every tab e.g. (products logs, user logs, customer logs ....) I get all there log data successfully.

enter image description here

enter image description here

Now I want to show all logs data in All tab like in other tabs.

I tried query by my own but it shows me every thing separately.

Here is my query

SELECT * FROM tbl_product_log, tbl_user_log, tbl_customer_log, tbl_vendor_log, tbl_quotations_logs Limit 20

And here is result

enter image description here

So please tell me how can I achieve this, that all logs data show in All tab only in three columns like other tabs show the result with one query.

Hop you understand my question.

  • 写回答

3条回答 默认 最新

  • duanaoreng9355 2017-07-20 06:33
    关注

    use union to connect all tables

    (Select * From tbl_product_log LIMIT 5)
    
    union
    
    (Select * From tbl_user_log LIMIT 5)
    
    union
    
    (Select * From tbl_customer_log LIMIT 5)
    
    union
    
    (Select * From tbl_vendor_log LIMIT 5)
    
    union
    
    (Select * From tbl_quotation_log LIMIT 5);
    

    notes : this query will produce a total of 25 records

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

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码