Skip to content
Advertisement

Search between two SQL tables?

I have two tables:

student

Columns

teacher_accounts

Columns

I have an input form that takes the data entered into an input field, and passes it through the following SQL query:

However, I want to now join the teacher_accounts table to see if the name entered possibly matches what is entered into the input field. Essentially I need an SQL statement that checks the teacher_accounts and student table against the data entered into the input field.

Thanks for any help!

UPDATE

I need to mention that I’m outputting this data using mysql_fetch_array, so I need a way for the script to discern whether or not it needs to pull from the teacher columns or the student columns.

Advertisement

Answer

Refer to: http://dev.mysql.com/doc/refman/5.6/en/sql-syntax-prepared-statements.html for how to prepare statements and pass values safely using placeholders.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement