输出结果?
貌似
for(...){//循环求出表名
....
tableabcxyz= talbe1,talbe2,...talbe3
}
$str="SELECT * FROM talbeabcxyz having ( 职业 like '%医生%') limit ".($page-1)*$num."
....
求解。
------解决方案-------------------- 每张表建立外键,可将所有表链接起来查询。 如:表1: CREATE TABLE `mis_link` ( `lid` int(6) NOT NULL, `cid` int(6) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 表2: CREATE TABLE `mis_commodity` ( `cid` int(6) NOT NULL auto_increment, `comName` varchar(20) NOT NULL, `comPrice` varchar(20) NOT NULL, PRIMARY KEY (`cid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 表3: CREATE TABLE `mis_order` ( `oid` int(6) NOT NULL auto_increment, `sid` int(6) NOT NULL, `cid` int(6) NOT NULL, `ordTime` varchar(20) NOT NULL default '', `ordPrice` varchar(20) NOT NULL default '', PRIMARY KEY (`oid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
SQL code
select o.oid,l.lid,c.cid,comName,comPrice,ordTime
from mis_order o,mis_link l,mis_commodity c
where o.oid=l.lid and c.cid=l.cid;
------解决方案-------------------- talbe 就没懂啥意思...table就有点明白了...
select name from table1 where name like "obama%" union select name from table2 where name like "obama%"