Skip to content

Tag: join

SELECT from table with count from another

I have 2 mysql tables I need to get all views by user, but also need to get the user role (for each view) and calculate a dynamic number of users used for every view. So, I need to get all view columns, plus the role of the user which do this request (from ViewUser), plus count of users for

SQL query join tables data

I have 2 tables Users and TimeSheets, Timesheets table has column UserId which is users id form users table obviously 🙂 Logic And I’m trying to get all data of Timesheets table plus just name of user from users table but somehow it seems like my query is other way around! Now I know this might be a simp…

SQL Insert into with join and where

I have three tables. For example: newTable: oldTable: associativeTable: What I want to do now is: I want to move the name column from oldTable to newTable. I have already altered newTable and added an empty name column. Now I’m trying to write a correct INSERT INTO statement. What I have so far is: I&#8…