FastPrepFind Rows Common to Two Tables
Problems/Find Rows Common to Two Tables

Find Rows Common to Two Tables

Salesforce logoSalesforce● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: Reported in a Salesforce phone screen. The report asks for the rows two tables have in common and mentions joins or set intersection. It gives no table layout and does not say what to do with duplicates. Here each table has two columns with no empty values. Two rows match only when the whole row is equal. Each result is listed once, in a fixed order. Our version is about 70% the same as the reported question.

Find the rows that appear in both left_records and right_records. Both tables have the columns record_id and record_text.

Return every row that appears in both tables. Two rows match only when both columns are equal. Return each common row once, even if an input has duplicates. Output the columns record_id and record_text, sorted by record_id ascending and then by record_text ascending.

Assume that neither column is ever null.

Table schema

MySQLPostgreSQLPandas

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

ColumnTypeNullableDescription
record_idIntegerNo—
record_textTextNo—

right_records

ColumnTypeNullableDescription
record_idIntegerNo—
record_textTextNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
record_idIntegerNo—
record_textTextNo—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • Each table contains between 0 and 1000 rows; duplicate rows are allowed.
  • -1000000 <= record_id <= 1000000.
  • record_text contains 1 to 30 lowercase English letters.
  • Neither column contains null values.

More Salesforce Phone Screen questions

  • Detect a Cycle in a Linked ListPHONE SCREEN · Seen Oct 2026
  • Merge Two Sorted Linked ListsPHONE SCREEN · Seen Oct 2026
  • Minimum Window of Required WordsPHONE SCREEN · Seen Aug 2026
  • Permutations of Unique CharactersPHONE SCREEN · Seen Aug 2026
  • Minimum Window SubstringPHONE SCREEN · Seen Aug 2026
  • Optimal Account BalancingPHONE SCREEN · Seen Jul 2026
  • Longest Increasing SubsequencePHONE SCREEN · Seen Jul 2026
  • Maximal SquarePHONE SCREEN · Seen Jul 2026
  • ATM Queue Exit OrderPHONE SCREEN · Seen May 2026
  • Good Ways to Split an ArrayPHONE SCREEN · Seen May 2026

Similar questions at other companies

  • Second Highest SalaryPaytm · PHONE SCREENPaytm interview questions
  • Employees Who Earn More Than Their ManagersNykaa · PHONE SCREENNykaa interview questions
  • Employees Who Joined More Than a Week AgoNewgen Software · PHONE SCREEN
  • Departments Without EmployeesDell Technologies · PHONE SCREENDell Technologies interview questions
  • Second-Highest Distinct SalaryChubb · PHONE SCREENChubb interview questions
  • Swap Two Gender ValuesInfosys · PHONE SCREENInfosys interview questions
  • Count Records Present in A but Not BCapital One · PHONE SCREENCapital One interview questions
  • Customer Order Count Distribution by CountryApple · PHONE SCREENApple interview questions
  • Employees Earning More Than Their ManagerMygate · PHONE SCREENMygate interview questions
  • Classify Tree Nodes with SQLOracle · PHONE SCREENOracle interview questions

Salesforce interview experiences

  • Salesforce Infrastructure SWE OA and Onsite: 1 Experience
  • Salesforce Experienced Backend SWE First Round: 1 Experience
All Salesforce interview questionsSee Salesforce hiring insights