Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting certain column to a table then display it to another table

I’m a beginner at sql and I would like to know if it is possible to get only a certain column then display it into another table.

Here’s an example:
I have a table named ‘users’, this table consist of id, name, address, email, password, and dateRegistered.

I have another table named ‘activities’. Which consist of id, userid, activity, and date_time.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I would like to get the columns id and dateRegistered from ‘users’ table and display it into ‘activities’ table where ‘userid’ = ‘id’ and ‘date_time’ = ‘dateRegistered’.

ps. I would like to add that I’m using MySQL database or xampp what ever you called that.

>Solution :

please required columns in select clause and use join.

select 
u.* ,-- all columns for users table
a.* -- all columns for activity table

from users u inner join activities a on u.userid= a.id and u.date_time=a.dateRegistered
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading