Filter with 2 databases

QuestionsFilter with 2 databases
Robby asked 11 years ago

Hi friends,

I have a problem with a grid.
I did one with SQL request to MySQL.
The query is:
"SELECT c.Customer, c.Name, c.Adress_1, c.Adress_2, c.Zip_Code, c.City, …, COUNT(*) as Nombre FROM db_access i LEFT JOIN db_customer c ON i.Customer = c.Customer GROUP BY i.Customer"

In the top of my grid, I put filters.
It works find with all of them, but if I when to filter on Customer, I have an error message about "Couldn't execute query. Column 'Customer' in where clause is ambiguous"

If I change my query to:
"SELECT c.Customer as Customer, c.Name, c.Adress_1, c.Adress_2, c.Zip_Code, c.City, …, COUNT(*) as Nombre FROM db_access i LEFT JOIN db_customer c ON i.Customer = c.Customer GROUP BY i.Customer"

The problem still the same.

If I put:
"SELECT c.Customer as MyCustomer, c.Name, c.Adress_1, c.Adress_2, c.Zip_Code, c.City, …, COUNT(*) as Nombre FROM db_access i LEFT JOIN db_customer c ON i.Customer = c.Customer GROUP BY i.Customer"
In this case the message says that MyCustomer doesn't exist in my database.

Does someone could help me?

Thanks.

Robby

3 Answers
Abu Ghufran answered 11 years ago

You have to use dbname with column setting.

$col["dbname"] = "c.Customer";

Robby answered 11 years ago

Hi Abu,

Thanks a lot.
It works very nice.

Regards.

Robby

Scultetus answered 8 years ago

Thank you Abu,

This help me too.

Regards,
Scultetus.

Your Answer

12 + 8 =

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?