Home > front end >  Getting certain column to a table then display it to another table
Getting certain column to a table then display it to another table

Time:11-30

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.

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.

CodePudding user response:

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
  • Related