Re: Making a Variable from different tables with Matching Db fields?
| From: | Andrew Ballard | Date: | Wed, 28 Jan 2009 21:33:11 +0000 |
| Subject: | Re: Making a Variable from different tables with Matching Db fields? | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287316@lists.php.net to get a copy of this message | ||
On Wed, Jan 28, 2009 at 4:31 PM, Terion Miller <webdev.terion@gmail.com> wrote:
> On Wed, Jan 28, 2009 at 3:22 PM, Christoph Boget <christoph.boget@gmail.com>
> wrote:
>>
>> > Well I'm stuck I have the AdminID but now I can't seem to use it to pull
>> > workorders with that AdminID . I couldn't get your block to work Andrew
>> > :(
>> > I think I'm just not using it right now that I have it...lol
>>
>> Because there is ambiguity w/r/t the columns you are selecting, you'll
>> need to use aliases.
>>
>> http://dev.mysql.com/doc/refman/5.1/en/identifiers.html
>>
>> In your code, when you are referencing the column, do so using the
>> alias. That should solve your problem.
>>
>> thnx,
>> Christoph
>>
> I just read it 3 times and I don't understand it.
>
Try this... (just make sure to assign a valid $username value.)
$sql =
"SELECT workorders.WorkOrderID , workorders.AdminID
FROM workorders
INNER JOIN
admin
ON workorders.AdminID = admin.AdminID
WHERE admin.UserName = '" . mysql_real_escape_string($username) . "'";
Andrew