I am having trouble adding two columns together which are from the same table.column, with two different values.
How do I add the following two queries together to give two new columns with each their own value;
SELECT
... more columns ...
components.description,
FROM
...
WHERE
graphiccards.id = systems.id AND
components.id = graphiccards.component_id;
SELECT
components.description
FROM
...
WHERE
components.id = mainboards.component_id AND
mainboards.id = systems.mainboard_id
I would like these two results to be on the same row in two different columns.
You may wish to look at the UNION
operator
select
components.description
stuff as second_column
from mytable where conditions
union
select
components.description
stuff2 as second_column
from mytable2 where conditions2
You just need to make sure you have the same nr of columns with the same name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.