phone is foreign key that link to first table. there is no primary key in second table. so altogether i have 6 fields in 2 tables (name, phone, e-mail, yahoo id, google id, ICQ#)

i want to search someone from my table with all 6 parameters (not necessarily all, but user have option to search by no parameter, 1, 2, 3, 4, 5, or all 6 parameters from the form), and display their name only in ascending order.

the form have 6 text fields, and a submit button. if user submit the form empty, then i'll just list all the name. now the user would fill up any number of field and i would have to search from both tables.

the condition to use when searching is LIKE (if only 1 table it would be SELECT * FROM TABLE1 WHERE NAME LIKE '%$name%' ORDER BY NAME ASC)

so, now i have 6 parameters and 2 tables. how do i extend this query to include all 6 parameters? can anyone help me write the query?