2016-11-10 21:03



I have two tables,one is called patient_payments and the other is patient_billing.i now want to select all the rows from each table and then present them as a single list in my webpage.I am using laravel framework and i have used raw query as follows

$items = DB::select(DB::raw('select * from patient_payments pp,patient_billings pb'));

One table has three rows and the other five rows and i was expecting two get eight rows but the query returns 14 rows which is wrong.Any idea what is wrong with my query is much appreciated.

Thanks in advance

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dougong1031 dougong1031 5年前

    If both tables have the same number of columns, you can use union() method like this:

    $items = DB::table('patient_payments')

    Read more about Laravel Query Builder: union() here.

    Hope this help.

    点赞 评论 复制链接分享