This topic is locked

ambigous column username

3/28/2007 11:28:44 AM
PHPRunner General questions
hax0r author

I've created a phprunner page for two tables - requests and replies. Each has a column called username. I want to make use of the login functionality and display information from both tables. However, I get an error that username is ambiguous.
I assume that the login functionality ignores the current table and appends something like WHERE username = 'Logged_in_username' to my query. Am I doing something wrong? Is there a way to fix this? Renaming the columns is not an option since half a dozen other systems already use these tables.
Thanks.

Sergey Kornilov admin 3/28/2007

When you use a JOIN SQL query that pulls data from more than one table use table prefixes to avoid ambiguity.

select a.OrderID,

CustomerName

from Orders a

inner join OrderDetails b

on a.OrderID = b.OrderID
B
bencroft 1/9/2008

I've created a phprunner page for two tables - requests and replies. Each has a column called username. I want to make use of the login functionality and display information from both tables. However, I get an error that username is ambiguous.

I assume that the login functionality ignores the current table and appends something like WHERE username = 'Logged_in_username' to my query. Am I doing something wrong? Is there a way to fix this? Renaming the columns is not an option since half a dozen other systems already use these tables.
Thanks.


I think you can just change the name used (and keep the field the same) i.e.
[dbo].[Customers].[Contact],

[dbo].[SalesActivity].[Contact] as [Contact1],
This will get rid of the error and let you choose which field you want to use (I think - I am a newbie though!!)
Ben