SELECT t.dateline AS date,t.tid, t.subject, u.avatar,t.views, t.username, t.replies, u.profilepic, t.uid, p.thumbsup, t.firstpost, f.name, f.fid, p.message, a.updatetime, a.md5hash, a.uploadtime, a.aid, a.attachname, a.filename, a.thumbs, td.vidid, td.cat, td.portada
FROM ". TABLE_PREFIX ."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=t.fid)
LEFT JOIN ".TABLE_PREFIX."xtattachments a ON (a.tid=t.tid)
LEFT JOIN ".TABLE_PREFIX."threadfields_data td ON (td.tid=t.tid)
LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=t.firstpost)
WHERE t.fid IN ($f4id) AND t.uid IN ($show_post_list)
UNION ALL
SELECT th.dateline AS date, th.thumbsup, th.uid
FROM ". TABLE_PREFIX ."thumbspostrating th
ORDER BY date DESC
LIMIT ".(($page-1)*$perpage).", ".$perpage);
示例:
我不知道为什么这不起作用?
在ORDER BY
< - 我需要t.dateline
和l.dateline
进入一个例子。
1222 - 使用的SELECT语句具有不同的列数
答案 0 :(得分:1)
您可以尝试将选择SELECT l.dateline添加为日期行作为日期行,l.name,l.avatar。
这对我有用。如果这不起作用,您可以随时对您的选择进行选择,然后订购该结果,它将读取类似这样的内容
SELECT dateline, name, avatar FROM (
SELECT t.dateline, t.name, u.avatar
FROM ". TABLE_PREFIX ."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
UNION ALL
SELECT l.dateline, l.name, l.avatar
FROM ". TABLE_PREFIX ."likes l
LEFT JOIN ".TABLE_PREFIX."treads t ON (t.uid=l.uid)
) as x
ORDER BY x.dateline DESC
LIMIT 10;
答案 1 :(得分:0)
ORDER BY
仅适用于第二个查询:
Select * From (
SELECT t.dateline, t.name, u.avatar
FROM ". TABLE_PREFIX ."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
UNION ALL
SELECT l.dateline, l.name, l.avatar
FROM ". TABLE_PREFIX ."likes l
LEFT JOIN ".TABLE_PREFIX."treads t ON (t.uid=l.uid) ) allData
ORDER BY allData.dateline DESC
LIMIT 10;