Re: Making a Variable from different tables with Matching Dbfields?
| From: | Chris | Date: | Wed, 28 Jan 2009 23:12:34 +0000 |
| Subject: | Re: Making a Variable from different tables with Matching Dbfields? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287336@lists.php.net to get a copy of this message | ||
Terion Miller wrote:
I'm not sure what you mean by trim the posts, please explain so I can spare folks from redundant text.Before you post, remove any text that you're not referencing (in this case I removed my suggestion).
Your post made perfect sense to me about the INNER JOIN , I looked it up but it is not returning the AdminID, maybe my syntax is wrong?
$query = "SELECT admin.AdminID , workorders.AdminID
FROM admin
INNER JOIN
workorders
ON AdminID(admin, workorders)
WHERE admin.UserName = '".$_SESSION['user']."' ";
The syntax is wrong.
inner join workorders using (adminid)
^^
only works if both tables are using the same field name, the db will expand it into the syntax below. Here you just need to specify the fieldname to join on (ie the common one).
or
inner join workorders on (admin.adminID=workorders.adminID)
^^
if the field names are not named the same, eg:
select * from
comments
inner join users on (comments.user_id=users.id)
You have to use the full tablename (or alias) and the field name.
--
Postgresql & php tutorials
http://www.designmagick.com/