Primary key search in grid not working when i'm using inner join in query

QuestionsPrimary key search in grid not working when i'm using inner join in query
Alén asked 7 years ago

I used a select_command like:

$a->select_command = "SELECT $t1.Contract, $t1.Name, $t1.Text, $t2.ID, $t2.Model FROM $t1 INNER JOIN $t2 WHERE $t1.Contrat = $t2.Contrat ";

When i search from Name, Text, ID or Model I don't have any problems but I can't search for Contract. When I try it Grid return: "Couldn't execute query. Column 'Contrato' in where clause is ambiguous" […]

Anyone knows why it's not working?

Thank you for helping.

2 Answers
Abu Ghufran answered 7 years ago

Hi,

You need to set dbname property to resolve ambiguity.
You can specify exact table.field then it will be used in where clause.
With contrato column,

$col["name"] = "Contrat";
$col["dbname"] = "$t1.Contrat";

Alén answered 7 years ago

Hi,

thank you this solution works perfectly.

Your Answer

7 + 19 =

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?