Hello all how can get two same name column from two different table as single result in two different column as combine result.
Eg: customer table have column customerid
custmerId | customerName |
---|---|
1 | row |
2 | row |
Order Table
it has also column customerid
custmerId | orderName |
---|---|
1 | order1 |
4 | order2 |
5 | order3 |
Expected Output
custmerId | custmerId |
---|---|
1 | 1 |
2 | 4 |
5 |
Note: There is no relation between both table
3
Answers
it’s not possible. it’s better to use aliases or group by.
you can use alias, a ‘SELECT AS’, to seprate column names:
If by result, you mean a simple SELECT query result, you can just indicate the column name in a SELECT clause and separate the table names with a comma in the FROM clause. see example below:
SELECT customerID FROM Customers, Orders;
You can also add a "WHERE" clause at the end if you have conditions the query needs to meet.
MySQL does not support FULL JOIN, so
Remember that an outer client software which accesses the output rowset columns by the name (not by the posession) won’t print the result correctly. In this case you must assign unique aliases to the output columns. For example,
.. SELECT cte1.customerId AS customer_id, cte2.customerId AS order_id ..