SELECT * FROM dog WHERE (SELECT calluser FROM jos_users WHERE `user_id`='".$cid."')=Subcode
$cid may be the identifier in
jos_users, which informs us which customers we are fetching data about
The information I wish to fetch is at "dog", and calluser may be the identifier between your two (which informs us who's dogs are who's)
I have to have the ability to call just the dogs highly relevant to the consumer under consideration, it needs to be carried out in a single query. Can anybody help? Much appreciated.
Basically got you right (and also the id column within the dog-table links towards the calluser column within the jos_user-table) the query ought to be
SELECT d.* FROM dog AS d JOIN jos_user AS u ON d.id = u.calluser WHERE u.user_id = '$cid'
Otherwise please explain your computer data structure in greater detail (maybee small ER diagram).
You should utilize joins.
Look at this tutorial: http://www.tizag.com/mysqlTutorial/
Your query need to look something similar to this:
$cid = mysql_real_escape_string($_GET['cid']); $query = "SELECT d.* FROM dog d INNER JOIN jos_users ju ON (d.user_id = ju.id) WHERE ju.id = '$cid' ";