Im working on a picker routine where you can search en choose items for a branche or something else you would like. Ive got the SQL statement if you want to search in one table. But now I also want to search in two or more tables but now I get the error
Column owner_id found in more than one table – need a correlation name.
This is my generated SQL which I use:
var vQuery = "SELECT " + vTableColumns + " FROM " + vTables + " WHERE owner_id = " +ownerId + " AND owner_loc_id = " + ownerLocId + vCustomWhereClause
Now I fill those vars and it says that owner_id is in one or more tables. How can I solve this?
If every table you use has this owner_id then why not assign a default aliasname to the first used table. Then use this standard alias in your code for your owner_id. Of course you will need to use this alias for all the columns as well.
globals.core_DIALOG_showSelectDialog('SERVER, 'product myAlias , branche AS b','myAlias .product_id, myAlias.description, b.branche', COL_NAMES, 'myAlias.product_type_id ASC', true,'myAlias.branche_id = b.branche_id');
```Will result in:
SELECT myAlias .product_id, myAlias .description, b.branche FROM product myAlias, branche AS b WHERE myAlias.owner_id = 0 AND owner_loc_id = 0 AND (myAlias.branche_id = b.branche) ORDER BY yAlias.product_type_id ASC