|
Posted by Stefan Rybacki on 10/09/02 11:27
Josua Burkard wrote:
> Hello
>
> I have two Tables in MySQL: One with my Users (including Administrators and
> normal Users) and one with Support Tickets.
>
> Now i have an SQL-Statement, wich is running in phpMyAdmin without Problems:
> SELECT *
> FROM (
> `HD_tickets`
> INNER JOIN HD_users AS HD_users1 ON HD_tickets.tuID = HD_users1.uID
> )
> INNER JOIN HD_users AS HD_users2 ON HD_tickets.tSupporterID = HD_users2.uID
>
> I Join the user Table for two times with the ticket-table
>
> in php i use this code:
>
> $sql = "SELECT * FROM (`HD_tickets` INNER JOIN HD_users AS HD_users1 ON
> HD_tickets.tuID = HD_users1.uID) ";
> $sql .= "INNER JOIN HD_users AS HD_users2 ON HD_tickets.tSupporterID =
> HD_users2.uID ";
> $query = mysql_query($sql);
> if (mysql_num_rows($query) != 0)
> {
> while ($rst = mysql_fetch_array($query))
> {
> echo $rst['uName']; // From Table HD_users1
> echo $rst['uName']; // From Table HD_users2
> }
> }
>
> Now my Question:
> How can i different in the $rst['userName'] from which table this is? From
> HD_users1 and HD_users2.
>
Don't use SELECT *, use SELECT column1, column2 instead. This way you can easy get your
uNames like this:
SELECT HD_users1.uName as HD_users1uName, HD_users2.uName as HD_users2uName ...
Regards
Stefan
> Best regards
> Josh
>
>
Navigation:
[Reply to this message]
|