Re: Making a Variable from different tables with Matching Dbfields?
| From: | Terion Miller | Date: | Wed, 28 Jan 2009 23:39:24 +0000 |
| Subject: | Re: Making a Variable from different tables with Matching Dbfields? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287341@lists.php.net to get a copy of this message | ||
>
>
> 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)
>
> Well I tried both ways and still cannot get it to pick up the AdminID,
$query"SELECT admin.AdminID , workorders.AdminID FROM admin INNER JOIN
workorders on AdminID WHERE admin.UserName = 'tmiller'
"$result""$row""
$SortBy"WorkOrderID
DESC"$Page"1"$PerPage"30"$StartPage"0"$sql"SELECT
admin.AdminID , workorders.AdminID FROM admin INNER JOIN workorders ON
AdminID(admin, workorders) WHERE admin.UserName = 'tmiller' "$Total"0"