Jump to content

[Solved] Update db SQL-LITE


raynner

Recommended Posts

I am making a home system for my rpg server and everything went well until I ran into a problem not updating information in my db file where the data of each house is stored in case I find it difficult to change the house DONOR informing the ID of the house on the "WHERE" ("WHERE ID =?") Camp could anyone help me with this problem as this is a key point in my roadmap and for it to work correctly. I am new to SQL and its functions in MTA-Moon and in Moon.

My Problem is the db not is Update ! 
My db does not update if I provide an id if I do not set a location to "WHERE" it does an update on all but I need only the ID I want.

 

Solved conclusion

Apparently ID is a key word in SQL or MySQL so I do not advise using "ID" as a table name

 

Edited by raynner
Edit Descrition
Link to comment
  • Administrators

Are you sure it's a reserved word? I've never seen that before.

For future reference, if you ever "need" to use reserved keywords in your query (plzno), simply use backticks, e.g:

SELECT * FROM `SELECT` WHERE `COLUMN_NAME` = 'somedata'

 

Edited by LopSided_
Link to comment
Just now, LopSided_ said:

Are you sure it's a reserved word? I've never seen that before.

For future reference, if you ever "need" to use reserved keywords in your query (plzno), simply use backticks, e.g:


SELECT * FROM `SELECT` WHERE `COLUMN_NAME` = 'somedata'

 

As I said I have solved it but I do not believe it was for the reason I quoted above, but rather why I should define the column as type TEXT.

 

Old Code

dbExec(dbh, "CREATE TABLE IF NOT EXISTS HouseList (ID, Owner)")

New Code
 

dbExec(dbh, "CREATE TABLE IF NOT EXISTS HouseList (ID TEXT, Owner TEXT)")

 

Edited by raynner
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...