Table join with same column name

QuestionsTable join with same column name
Cedric asked 7 years ago

Hello,
I have an issue with datagrid when uing a query with a JOIN on 2 tables that have a same column name.
The grid work, but the search filter on the column that is in the 2 tables return an ambigous sql error
using alias does not really help…
here is the query:

SELECT
DISTINCT (cc.CCid),
DATE_FORMAT(cc.CCdate, “%d/%m/%Y”) AS CCdatemod,
cc.CCstatus,
cc.Custfax,
CCinvestigator,
cc.Salesrep,
CP.Pname,
“Edit” as edit_link,
cc.CCid as pdf_link
FROM cc
JOIN cc_products CP ON (cc.CCid= CP.CCid)
GROUP BY cc.CCid

CCid is the column causing problem in search.
A tip to fix this?
Thanks,
Cedric

2 Answers
Abu Ghufran Staff answered 7 years ago

You need to specify table.field to resolve ambiguity.

$col["dbname"] = "cc.CCid";
_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
c answered 7 years ago

Thanks,
That fixed the issue.

Your Answer

7 + 14 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?