Find Rows Common to Two Tables
Problem statement
Find the intersection of left_records and right_records. Both tables contain the columns record_id and record_text.
Return every complete row that appears in both tables. A match requires both columns to be equal. Return each common row exactly once, even when an input contains duplicates. Output the columns record_id, record_text, ordered by record_id ascending and then record_text ascending.
For this exercise, assume the two-column non-null schema, full-row equality, distinct-row semantics, ordering and bounds below. These are practice conventions completing the reported two-table intersection task.
Table schema
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
left_records
| Column | Type | Nullable | Description |
|---|---|---|---|
| record_id | Integer | No | — |
| record_text | Text | No | — |
right_records
| Column | Type | Nullable | Description |
|---|---|---|---|
| record_id | Integer | No | — |
| record_text | Text | No | — |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| record_id | Integer | No | — |
| record_text | Text | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- Each table contains between
0and1000rows; duplicate rows are allowed. -1000000 <= record_id <= 1000000.record_textcontains1to30lowercase English letters.- Neither column contains null values.