Re: Making a Variable from different tables with Matching Dbfields?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Terion Miller wrote:
> Well upon looking it was number 2, I had no orders in the workorder table,
> but here is an oddity I wonder if someone can explain if I run this simple
> query:
> 
>  $query =  "SELECT * FROM admin, workorders
>       WHERE   admin.UserName =   '".$_SESSION['user']."' ";
> 
> It returns adminID = 7 (my number is 20) username= tmiller (this is correct)
> 
> 
> it's the only query I can get to return anything but it's the wrong adminID
> can someone explain what can be making that happen
> 

You cannot return related values from 2 tables without joining the
tables in the query which we've shown is not going to work because you
need to get AdminID from admin before you can join it to workorders.

What your query says is, "give me all fields for all rows from admin,
where UserName = the session user, and give me the same number of rows
from workorders arbitrarily or just the first however many rows".  I
would be willing to bet that the first record in workorders has AdminID = 7.

This works, obviously:

$query =  "SELECT * FROM admin WHERE admin.UserName =
'".$_SESSION['user']."' ";

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux