I am trying to join the output of two select statement, since each select statement will return 0 or 1 output, INNER JOIN will return nothing in case of one returning 0 output. I was wondering how OUTER join can be done. I have seen solution for INNER JOIN and have got that one to work but, when I change it to OUTER JOIN I get this error:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OUTER JOIN (SELECT value FROM server_setting WHERE server_id=1 AND server_sett' at line 3
here is the query:
SELECT * FROM
(SELECT `value` AS url FROM server_setting WHERE server_id=1 AND server_setting_type_id=(SELECT min(id) FROM server_setting_type WHERE type='url')) AS t1
FULL OUTER JOIN
(SELECT `value` AS port FROM server_setting WHERE server_id=1 AND server_setting_type_id=(SELECT min(id) FROM server_setting_type WHERE type='port')) AS t2
;
sample input:
server_setting table:
|---------|----------------------|-----|
|server_id|server_setting_type_id|value|
|---------|----------------------|-----|
|1 |1 |http |
|1 |2 |22 |
|---------|----------------------|-----|
server_setting_type table:
|--|----|
|id|type|
|--|----|
|1 |url |
|2 |port|
|--|----|
Result:
|----|----|
|url |port|
|----|----|
|http|22 |
|----|----|
thanks
Full Outer joinorleft outer joinorright outer joinOUTER JOINin your query above withUNION. As your query stands right now, if you got it working it would have one row with two columns namedvalue. If you don't want to append results could you add sample data and expected results to your question?