dumdumsareyum Posted May 29, 2009 Share Posted May 29, 2009 I have two columns "first_name" and "last_name" returned as a single column "name" . I only want the values of that occur in the table "employees" that don't occur in table "out_board". So far I have this to return only the rows from employees that don't occur in out board: SELECT employees.* AS name FROM employees LEFT JOIN out_board ON employees.id=out_board.id WHERE out_board.id IS NULL; and this to combine the columns: SELECT CONCAT_WS(" ", first_name, last_name) AS name FROM employees; but I don't know how to combine the two so I only get the concatenated name column from my join. Thanks! Link to comment https://forums.phpfreaks.com/topic/160209-solved-join-tables-and-rename-fields/ Share on other sites More sharing options...
roopurt18 Posted May 29, 2009 Share Posted May 29, 2009 SELECT CONCAT_WS(" ", a.`first_name`, a.`last_name`) as `name` FROM `employees` as a LEFT JOIN `out_board` as b ON a.`id`=b.`id` WHERE b.`id` IS NULL; Alias the tables to save yourself some typing. In the SELECT portion, you just identify which columns from which table you want, just like you always do. Link to comment https://forums.phpfreaks.com/topic/160209-solved-join-tables-and-rename-fields/#findComment-845334 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.