PHPNS Posted November 28, 2007 Share Posted November 28, 2007 Hi All, I'm selecting information from two MySQL tables using a UNION query. The data output will be in a list format. A snippet is as follows: $query = "select cl_id, cl_status from clients_confirm UNION select cl_id, cl_status from clients ORDER BY cl_id"; $result = @mysql_query ($query); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo $row['cl_status']'<br />'; } There are some rows (purposely) that will have the same number(id) from both tables (e.g cl_id from clients_confirm & cl_id from clients). Here is a sample list output: 1 cl_status 2 cl_status 2 cl_status (don't want this second one... or maybe the first) 3 cl_status 4 cl_status etc. I need to find a way to choose only one of the id's when two of the same (one from each table) are selected. In other words, I don't want duplicate rows echo'd. Can someone please help?? Thanks. Link to comment https://forums.phpfreaks.com/topic/79163-solved-table-comparison/ Share on other sites More sharing options...
PHPNS Posted November 28, 2007 Author Share Posted November 28, 2007 PS... I'm not picky about using this method. I just need a way to pick rows from two tables and order them by a specific column, while filtering out duplicate rows... Link to comment https://forums.phpfreaks.com/topic/79163-solved-table-comparison/#findComment-400698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.