select * from databasea.table1 union select * from databaseb.table2 ;
創(chuàng)新互聯(lián)主營門頭溝網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,手機APP定制開發(fā),門頭溝h5成都小程序開發(fā)搭建,門頭溝網(wǎng)站營銷推廣歡迎門頭溝等地區(qū)企業(yè)咨詢
不推薦垮庫使用.弊端太多
很簡單啊,可以選擇JION關(guān)鍵字。
比如 ?php
session_start();
include "conn/conn.php";
$s_sqlstr="select * from xs inner jion xs_kc on xs.xh=xs_kc.xh" order by xh Desc";
$s_rst = $conn-execute($s_sqlstr);
?
這就實現(xiàn)了兩個表的查詢,你也可以加別名,這樣更方便書寫
$sql
=
"select
gjd_callback.call_fee,
gjd_callback.call_time
from
gjd_callball,gjd_cs
where
gjd_cs.id=gjd_callback.call_id
and
gjd_cs.id=$id"
還可以:
$sql
=
"select
gjd_callback.call_fee,
gjd_callback.call_time
from
gjd_callball
left
join
gjd_cs
on
gjd_cs.id=gjd_callback.call_id
where
gjd_cs.id=$id"
這兩句都可以!
在這句代碼
"FROM " . $GLOBALS['ecs']-table('order_goods')." AS og, ".$GLOBALS['ecs']-table('order_info')." AS oi ".
后面加(注意點號的連接):
" LEFT JOIN ". $GLOBALS['ecs']-table('goods') . "AS g ON og.goods_id = g.goods_id ".
然后在開頭的sql語句后面這里加上你要的字段:
$sql = 'SELECT og.goods_id, og.goods_sn, og.goods_name,og.goods_attr, og.goods_number AS goods_num, og.goods_price, g.gonghuojia '.
最后你去測試看一下行不行.
$info=M('A')
-field('id,title,cate_id,type_id,type_name,cate_name')
-join('F ON A.type_id = F.type_id')
-join('G ON A.cate_id = G.cate_id')
-select();
BCDE表 以此類推,數(shù)組合并