SELECT *
FROM your_table
WHERE search_date_1 = (SELECT MAX(search_date_1) FROM your_table)
AND search_date_2 = (SELECT MAX(search_date_2) FROM your_table)
AND search_date_3 = (SELECT MAX(search_date_3) FROM your_table)
SELECT table1.jobno AS 'Job. No',
(SELECT CONCAT(`search_date_1`, ' - ', `last_search_by_1`) FROM table1 WHERE id IN (SELECT MAX(id) FROM table1 WHERE jobno = table1.`jobno` AND search_by_1 != '')) AS 'Search Option 1',
(SELECT CONCAT(`search_date_2`, ' - ', `search_by_2`) FROM table1 WHERE id IN (SELECT MAX(id) FROM table1 WHERE jobno = table1.`jobno` AND search_by_2 != '')) AS 'Search Option 2',
(SELECT CONCAT(`search_date_3`, ' - ', `search_by_3`) FROM table1 WHERE id IN (SELECT MAX(id) FROM table1 WHERE jobno = table1.`jobno` AND search_by_3 != '')) AS 'Search Option 3'
FROM `table1` AS table1
GROUP BY table1.jobno
2条答案
按热度按时间thtygnil1#
光环兄弟...
字符串
请测试此代码,如果正确请接受答案。
u0sqgete2#
我得到的查询结果是这样的
这是我的SQL查询:
字符串