MySQL multiple tables How to find the contents of the content by the last update time arrangement
Field four tables are the same, only the content is different
Table name: AAA,BBB,CCC,DDD Four tables
Table field: Title,classid,userid,newstime,classname,images
I now want to put four independent tables without any association, to find out the last update (newstime) of the descending, and userid=2, 10 records of the content out how to write?
Newstime Field UNIX timestamp format
The UserID field is a field of the user ID (that is, to find out what the user last updated by 10 in descending order of time)
Reply to discussion (solution)
Select A.* from AAA as a UNION ALL select b.* from BBB as B union ALL select c.* from CCC as C union ALL select d.* from D DD as D where UserID = 2 newstime desc LIMIT 10
Upstairs positive solution.
Test it, please.
Select A.* from AAA as a UNION ALL select b.* from BBB as B union ALL select c.* from CCC as C union ALL select d.* from D DD as D where UserID = 2 newstime desc LIMIT 10
$ecms _bq_sql= $empire->query ("Select A.* from Ds_ecms_nanxie as a UNION ALL select b.* from Ds_ecms_nvxie as B union all Select c.* from Ds_ecms_tongxie as C where userid=1 order by newstime desc limit 10 ");
$bqno = 0;
while ($BQR = $empire->fetch ($ecms _bq_sql))
{
The above write error
The used SELECT statements has a different number of columns
Select A.* from ***_ecms_nanxie as a UNION ALL select b.* from ***_ecms_nvxie as B union ALL select c.* from ***_ecms_tong Xie as C where userid=1 order by newstime DESC LIMIT 10
In addition to ask, four tables if the data on the 5W, so that the investigation will be suspended animation?
OK, there is a table field less, there is a little more