select names.name,test,from_id,test,text from names join test on names.id=test.from_id where test.to=1
答案 0 :(得分:0)
如果您只想获取最后一条记录,并且使用MySQL数据库,则可以使用LIMIT
并结合ORDER BY
:
SELECT names.name,test.from_id,test.text
FROM names JOIN test ON names.id=test.from_id
WHERE test.to=1
ORDER BY names.id
LIMIT 1