Skip to content

Insert into new table an id with several values

I’ve been struggling with this problem. I have 2 populated tables and a third empty one and I would like to populate the third with data from the other two. Correlate values The idea is to assign every single ID from the 1st table to entries (several) found in the 2nd table that respect the condition wh…

SQL – Trouble counting values

I have a Database named ‘IDMS’ and it has two columns named ‘Table’ and ‘Column’. I Need to do a simple query, list the values in ‘Column’ with a count of duplicates. I tried this and not joy. I have tried differing variations of that select and it’s not w…

Select the duplicate rows with specific values

How can I only get the data with the same ID, but not the same Name? The following is the example to explain my thought. Thanks. Expected Output: How I have done. But the result included the following parts that I do not want it. Answer One approach would be to use a subquery to identify IDs that have multipl…

Default sort my own order without sort by

I want to leave the order as is in the in Clause, however SQL output is ordered by ID I know how to achieve the result using a temp table. Is there a better way to do it? Answer Not sure what you mean by I know how to achieve the result using a temp table as you haven’t shown

Knex join on column belonging to same same table

Using Knex.js, I am attempting to query a table of users. The only columns that are important for this scenario are internal_id (key), name, and supervisor_id. Every user (except one) has a supervisor and their record stored the ID of that supervisor. When viewing an individual user record in my app, I want t…