我有兩個表格,其中一個是擱置工具,另一個包含位置等工具歷史記錄以及誰擁有它。我需要運行這個表的檢索問題,並嘗試這個MYSQL內聯加限制?
SELECT tblmaskin.*
FROM `tblmaskin`
INNER JOIN tblmaskinhistorik ON tblmaskin.maskinId=tblmaskinhistorik.maskinId
WHERE tblmaskin.maskin='".$_POST['sok']."'
OR tblmaskinhistorik.var='".$_POST['sok']."'
OR tblmaskinhistorik.anvandarnamn='".$_POST['sok']."'
但問題是,我只想要搜索的最後插入的行中的歷史表中的工具。例如,當您根據地點搜索工具時,您只想獲取現在使用的工具。
有沒有辦法做到這一點?
可能的重複http://stackoverflow.com/questions/12600527/accessing-last-inserted-row-in-mysql – Haris 2014-10-20 10:04:13
http://stackoverflow.com/questions/3619030/mysql-join-the-most-最近只有行 – 2014-10-20 10:11:29