php - Query that pulls results from tables A and B, then uses results to get rows from table A -


someone gave me query below previous question asked on stack overflow. it's supposed pull "submissionid" 2 tables, called submission , addresses, zip = '$zip'. (both "submissionid" , "zip" appear in 2 tables.)

then, field "title" corresponded of these "submissionid"s. field "title appears in table submission.

then, query generate list of of resulting "title"s.

how modify query this? query below seems omit results submission.

$sqlstr = "select s.title, s.points, s.submissionid          submission s           inner join addresses ad          on ad.submissionid = s.submissionid          ad.zip = '$zip'      order s.points desc, s.title asc"; 

just add or s.zip = '$zip' where clause. little additional tidying, query becomes:

select   submission.title, submission.points, submission.submissionid     submission join addresses using (submissionid)    submission.zip = '$zip' or addresses.zip = '$zip' order submission.points desc, submission.title asc 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -