Re: Re: Problems with INNER JOIN
| From: | danaketh | Date: | Thu, 29 Jan 2009 19:39:28 +0000 |
| Subject: | Re: Re: Problems with INNER JOIN | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-45911@lists.php.net to get a copy of this message | ||
Try that query in console or use Navicat/phpMyAdmin to run it. Remove the HAVING part to see if the SELECT returns what you need.
Terion Miller napsal(a):
Thanks Martin, oddly enough that still doesn't pull any results, it won't even print the variables if I try to list them to see, I know my db connection is good checked that, and can do really simple queries, would something be preventing a JOIN from working? When I Reveal my variables this query snippet:-- S pozdravem Daniel Tlach Freelance webdeveloper Email: mail@danaketh.com ICQ: 160914875 MSN: danaketh@hotmail.com Jabber: danaketh@jabbim.cz$sql = "SELECT admin.AdminID, workorders.WorkOrderIDFROM admin INNER JOIN workorders ON admin.AdminID=workorders.AdminID HAVING admin.username='".$_SESSION['user']."' ";$result2 = mysql_query ($sql); $row2 = mysql_fetch_assoc ($result2); $Total = ceil(mysql_num_rows($result2)/$PerPage);Returns this: $sql"SELECT admin.AdminID, workorders.WorkOrderID FROM admin INNER JOIN workorders ON admin.AdminID=workorders.AdminID HAVING admin.username='tmiller' "$result2""$row2"" Terion On Thu, Jan 29, 2009 at 11:56 AM, Martin Zvarík <mzvarik@gmail.com> wrote:This will work: $sql = " SELECT admin.AdminID, workorders.WHAT_YOU_WANT FROM admin INNER JOIN workorders ON admin.AdminID=workorders.AdminID HAVING admin.username='".$_SESSION['user']."' "; Terion Miller napsal(a): Hi Everyone! I am having problems getting an INNER JOIN to work and need-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpWhat I'm trying to do is match up AdminID's from two tables and display only that users orders, sounds simple enough right...but I can't get it to return the AdminID... My Query: $sql =some tips trouble shooting where the problem may be."SELECT admin.AdminID , workorders.AdminID FROM admin INNER JOIN workorders ON (admin.AdminID=workorders.AdminID) WHERE admin.UserName = '".$_SESSION['user']."' ";$result = mysql_query ($sql); $row = mysql_fetch_assoc ($result); $Total = ceil(mysql_num_rows($result)/$PerPage);Thanks for any tips on how else I can accomplish this... Terion