Is it possible to compare data from two tables at once in PCP? For example, there is a table in the users database and in the same comments database. The first table has an id field, and the second has a com_id. Is it possible to compare them if you connect both tables at once in the query?
<? $com_id=15; $id = 1; $q = '' .'SELECT *' .' FROM users AS T1' .' JOIN comments AS T2' .' WHERE T1.id='.$id .' AND T2.com_id='.$com_id .' LIMIT 1;'; $res = mysql_query($q); if ($result = mysql_fetch_object($res)) var_dump($result); ?>
In general, yes, you can also without joins. You can compare and direct treatment:
[ ... ] WHERE users.id = comments.com_id [...]