You have two tables with a one to many join based on a field named id. You need to find records in the parent table that are not represented in the child table. how would you accomplish this?
Answer / Dhanvendra Shukla
To find records in the parent table that are not represented in the child table, you can use a LEFT JOIN with a condition for NULL on the child table. Here's an example using SQL Server:
```sql
SELECT p.* FROM ParentTable AS p
LEFT JOIN ChildTable AS c ON p.id = c.id
WHERE c.id IS NULL;
```
In this query, a LEFT JOIN is performed between the parent and child tables. The WHERE clause filters out the rows where the id in the child table is NULL, which means those records are not present in the child table.
| Is This Answer Correct ? | 0 Yes | 0 No |
How can you log an error to the server event log from a stored procedure?
I HAVE A PI ON COL A THE NEXT DAY I WANT CHANGE THE PI ON COL B? PLS SEND ME THE ANS
How can you fix a poorly performing query?
What you can do to remove data from the cache and query plans from memory for testing the performance of a query repeatedly?
What are the 18 schemas?
Explain about the relational database?
What are cursors? Explain different types of cursors?
Can you have a nested transaction?
What is the difference between a primary index and a secondary index? What is a duplicate data entry in an index? Can a primary index contain duplicates?
What is the maximum length of an extended property?
Write the fastest query to find out how many rows exist in a table?
what is difference between primary key and unique key ?
Oracle (3253)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)