How can I combine two columns into one. For example, I have one table named "posts" and other "posts_shared"
"posts" have these columns:
po_id
po_id_user
"posts_shared" have these columns:
ps_post_id
ps_shared_by
What I need is to bring all the data from "posts" and "posts_shared" in only one column. How can i do this?
If you mean combining posts.po_id
posts_shared.ps_post_id
into one column and the same with po_id_user
and ps_shared_by
then use UNION
clause in your SQL query.
SELECT po_id, po_id_user
FROM posts
UNION
SELECT ps_post_id, ps_shared_by
FROM posts_shared;
But in order to make UNION
possible, corresponding fields in your posts
and posts_shared
tables should have identical types.
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.