SQL Error [1054] [42S22]: (conn=71) Unknown column 'gp_id' in 'field list'

644 Views Asked by At

Not sure what is going on here, or I'm just going blind from working on the same project for so long... So here's the question.... Something extremely simple..

DB: Maria 10.4.24 PHP: 8.1.6

If I run this query in DBeaver or PHPMyAdmin or PHP

DELETE FROM gps WHERE gp_id = 5

I get

SQL Error [1054] [42S22]: (conn=71) Unknown column 'gp_id' in 'field list'

This just stopped working, it was working, but just stopped....

If I rename the column to bob_id and run DELETE FROM gps WHERE bob_id = 5; it works...

Any ideas?

1

There are 1 best solutions below

2
Darcey On

ANSWER

Instead of just dropping the DB, I deleted all the tables bar the one in question (gps), then tried a delete, it still failed, same error "column not found".

So I went looking for triggers, constraints etc and from somewhere a trigger not known to me got created. This was trying to null the gp_id column in some other table that doesn't have that column in it.

I have foreign key relationship constraints in place to handle this via cascade on delete set to null, I think it must have been DBSchema's doing, it does weird things sometimes.

Dropped the trigger, re-build db and seeded it and all is well in the world once again...

So just an error message with not enough information to point me in the right direction.