I have a web form that collects 3 pieces of information (first name, last name, tesla) which are passed to a php script. I need the script to query 2 tables:
Table1: ID; FirstName; LastName
If the two tables have matching entries for the user form, then I want the MySQL query to return the ID from table 1
Table1: ID: 123; FirstName: Jack; LastName: Spratt
Table2: Tesla: 18
Because there is no matching row for Tesla (i.e. 18), I want the query to return 0 rows; if the user had entered "23", then I want the query to return "123" (the ID from matching row of table1)
What MySQL query will do this?