Deleting a whole column in SQLite -
Lorenc_ - 30.05.2011
Title says it all, how could i delete a column from a TABLE?
Something i wrote which wont work!
pawn Code:
stock DeleteGang(gangid)
{
new Query[256], DBResult:Result;
format(Query, sizeof(Query), "DELETE FROM `GANGS` WHERE `GANGID` = '%d'", gangid);
Result = db_query(Database, Query);
return db_free_result(Result);
}
Re: Deleting a whole column in SQLite -
woot - 30.05.2011
ALTER TABLE 'table_name' DROP 'column_name'
Re: Deleting a whole column in SQLite -
Lorenc_ - 30.05.2011
Damn, IDK where to use that but i just want to make something that will search for a certain GANGID and delete the place where the gang id is but the current code i have wont work basicly, if you're right do you mind posting an example to what i should do to do this
Re: Deleting a whole column in SQLite -
jameskmonger - 30.05.2011
Do you understand the difference between a column and a row?
Re: Deleting a whole column in SQLite -
Lorenc_ - 30.05.2011
Well, in mysql no, in SQL not really, i just started using sql a couple of days ago
and what i ment by COLUMN is the complete line of the gang
`GANGNAME`, `GANGID`, `GANGLEADER`
for example
Re: Deleting a whole column in SQLite -
woot - 30.05.2011
columns = |
rows = __
If you use the query you posted in your first post, that will delete the row which has %d as gang ID.
Or tell us what exactly you want to do, then it might be easier to explain ..
Re: Deleting a whole column in SQLite -
Lorenc_ - 30.05.2011
Well i want to delete the whole row with the gangid = '%d'
Damn lol i got confused with columns and rows the opposite way :/
Inside the Table (GANGS) this is the format given when each gang is created:
Code:
GANGNAME: GANGID: GANGLEADER:
test 1 [Nova]Lorenc
I thought about the same way you did before about the deleting thing, thats why i posted here to gather more information and how to achieve this.
Re: Deleting a whole column in SQLite -
woot - 30.05.2011
Supposing GANGID is an integer, try this instead;
DELETE FROM `GANGS` WHERE `GANGID` = %d
The query is definitely OK and should delete the row.
You also don't need to use free_result when deleting a row.
Re: Deleting a whole column in SQLite -
Lorenc_ - 30.05.2011
Alright, thanks.
pawn Code:
stock DeleteGang(gangid)
{
new Query[256];
format(Query, sizeof(Query), "DELETE FROM `GANGS` WHERE `GANGID` = %d", gangid);
db_query(Database, Query);
}
Thats how my code looks like now, not sure if it works or not.
Re: Deleting a whole column in SQLite -
jameskmonger - 30.05.2011
Test it and see! Although you may want to loop through all connected players, see if their gang == gangid, and if so set their gang to 0.