由于有一张比较大的表,无法上传到空间供应商的服务器(限制了最大只能上传4M的文件),因此只好将这张表分割成4张表。请教如何从这4张同类型表中查询数据,就象查询1张表一样。一张表时查询语句如下:
select * from wuyan where z1="'.$f.'"'.'order by rand()'
改成四张表后,查询语句如下,但执行时出错,请教如下修改:
select * from wuyan_a,wuyan_b,wuyan_c,wuyan_d where z1="'.$f.'"'.'order by rand()'
select * from wuyan where z1="'.$f.'"'.'order by rand()'
改成四张表后,查询语句如下,但执行时出错,请教如下修改:
select * from wuyan_a,wuyan_b,wuyan_c,wuyan_d where z1="'.$f.'"'.'order by rand()'
select * from wuyan_a where z1='".$f."' order by rand()
union all
select * from wuyan_b where z1='".$f."' order by rand()
union all
select * from wuyan_c where z1='".$f."' order by rand()
union all
select * from wuyan_d where z1='".$f."' order by rand()
union all
select * from wuyan_b where z1='".$f."'
union all
select * from wuyan_c where z1='".$f."'
union all
select * from wuyan_d where z1='".$f."'
order by rand();
csliyu:如何建一个VIEW,能不能详细讲解一下?
create view view_wuyan as
select * from wuyan_a where z1='".$f."'
union all
select * from wuyan_b where z1='".$f."'
union all
select * from wuyan_c where z1='".$f."'
union all
select * from wuyan_c where z1='".$f."';select * from view_wuyan order by rand();mysql视图要在mysql5.1版本以上才支持。