This topic is locked

v11 - will it break if all tables have a field called "id"

9/26/2024 5:05:25 PM
PHPRunner General questions
W
wfcentral author

In all my previous projects I have always called the main auto-increment key field "id".

Now it seems that in v11 this is causing issues.

I get an error on the tables page telling me that the field "id" is ambigious in several places.

Also, maybe this is why I cannot use joins on the Query Designer page???

Do I have to redo my database tables to not have fields anywhere with the same name?

One more thing - cannot right click on tables on the "tables page" to modify the fields anymore??

C
Chris Whitehead 9/27/2024

I always use id as the auto increment field in my databases.

It's not really the field name that is the issue, I think you're joining 2 tables which both have the field name of "id" and the "id" field is used in a condition, you just need to prefix the field name with the table name for example.

where table1.id=x and table2.id=y

M
MikeUk 9/27/2024

Using 'id' is almost standard practice, at least for me. As it makes it easier to remember the id fields for every table without have to look at the table.

It could also be if you are using an INNER join on a table where one of the target rows contains NULL values that are part of the query.
It's better to use LEFT join in cases where it is likely tohave NULL in one of the fields in the rows that you are trying to access.

Mike