Skip to content
Advertisement

Tag: select

How to understand the execution sequence of SELECT and ORDER BY

I googled the question and all answers said SELECT was executed before ORDER BY. But the simple example below (using MySQL and sakila database) gives the correct sorted results. Obviously, ORDER BY is not executed after SELECT, as customer_id is not selected by SELECT. Can anybody explain what happened? SELECT rental_date FROM rental ORDER BY customer_id LIMIT 10; Answer Is

For all entries in one table, add to another table

Database looks like this: table1 table2 I want to make a query that passes the same data for all ID’s into table2. So after the query the database would look like the following: table1 table2 I’ve tried to make some INNER JOIN queries, but I can’t seem to make it work. Any suggestions? Answer Do you want this? Normally, ids

INSERT SELECT statement with only one column for SELECT

I’m using SQL Server Management Studio 18 and I’ve got the following tables with the following columns: TableA TableB I want to do an INSERT SELECT into TableB, maybe something like the following: Basically, I just want to make an INSERT SELECT where I’m grabbing a column from another table (InternalEmplID), and then for the other columns (Month and Year),

Advertisement