I have two tables with similar information. First Table is suppliers and other table is suppliers_contacts. Is there a way to merge the two columns into one?
My suppliers
table looks like this:
id | contacts_name | email
-- | ------ | -------
1 | sujith | sujith@sujith
2 | mark |
3 | naveen | naveen@naveen
and supplier_contacts
table, like this:
suppliers_id | name | email
-- | ---- |
1 | sujith | sujith1@sujith
2 | user1 | user1@user1
2 | user2 | user2@user2
3 | naveen1 | naveen1@naveen1
3 | naveen | naveen2@naveen
And I want to get something like this:
contacts_name | name | email
-- | ------ | -------
sujith | sujith | sujith@sujith
sujith | sujith | sujith1@sujith
user1 | user1 | user1@user1
user2 | user2 | user2@user2
naveen | | naveen@naveen
naveen1 | naveen1 | naveen1@naveen1
naveen | naveen | naveen2@naveen
All the email id should come in one Column from both the tables.
I tried the query below:
SELECT
suppliers.name,
supplier_contacts.name AS name1,
supplier_contacts.email AS sup_c_email
FROM suppliers
JOIN supplier_contacts
ON suppliers.id = supplier_contacts.suppliers_id
Can anyone help me on this? Basically i want the emails from both the tables to come under one column also should show contacts_name and name from both the tables. If any name or contacts_name is NULL also its fine.