mysql
my query far select different column_names 2 tables , put under same column respectively.
in selection table c, want select once column same value.
example: c_id has 3 rows consist of value 52, select first row encountered skip rest, same goes row value 41.
is possible achieve adjusting current query or should find way?
table m table c ----- ----- ----- ----- ----- ----- | m_id |m_date |m_siri| | c_id | c_date| c_data| ----- ----- ----- ----- ----- ----- | 1 | 02-13 | 1 | | 52 | 01-12 | xxx | ----- ----- ----- ----- ----- ----- | 2 | 10-13 | 1 | | 41 | 11-13 | yyy | ----- ----- ----- ----- ----- ----- | 3 | 11-13 | 2 | | 41 | 12-13 | zzz | ----- ----- ----- ----- ----- ----- | 4 | 04-14 | 1 | | 52 | 08-14 | eee | ----- ----- ----- ----- ----- ----- | 5 | 01-15 | 2 | | 52 | 10-14 | xxx | ----- ----- ----- ----- ----- ----- (select m_id id, m_date date m m_siri='one' order m_date desc limit 2) union (select c_id id, c_date date c order c_date desc) order date desc
use distinct
keyword getting once record multiple.
(select m_id id, m_date date m m_siri='one' order m_date desc limit 2) union (select distinct(c_id) id, c_date date c order ch_date desc) order date desc
Comments
Post a Comment