Skip to content
Advertisement

Tag: join

Finding an ID not in another column

I’m working on a little SQL exercise, and am scratching my head an this problem. I am trying to find all the Employees to whom no other employee reports to. This is what the employees table looks …

Query to Id referencing to an ‘Id’ to the same table

I have a table AMZ_EMPLOYEE_DETAILS with Employee Id, Employee Name and Supervisor1 and Supervisor 2. The Supervisors are employee itself but represented by their name. My task was to replace the Supervisor names with their Ids. I have used the following query to obtain the solution but it uses sub-queries and the query does look optimized. For this I have

Unknown column in field list when use join MySQL

I have 2 tables like this: product_master: campaign_product: This tables link with foreign key product_id I want to get all product data with campaign_code column. I don’t want to get 2 campaign_product row with same product_id. So I use this query: It got error when I run: Error in query (1054): Unknown column ‘dmspro_mys_campaign_product.campaign_code’ in ‘field list’ How I can

Query works on SQLite but fails on SQL Server

The following query works for me in SQLite. But in SQL Server, it gives me an error. Invalid column name ‘VehId’. And the editor puts a red squiggly line under the last VehId (but not the first). As you might expect, Vehicles.Id is the primary key. I’m trying to find all foreign keys in Transactions that don’t reference any row

SQL perform AVG after MAX

I have two tables. Table1: | ID1 | ID2 | ID3 | ID4 | |—–+—–+—–+—–| | 200 | 125 | 300 | 201 | | 206 | 128 | 650 | 261 | | 230 | 543 | 989 | 403 | and Table2: | ID1 | ID2 | ID3 | ID4 | …

Advertisement