check if column exists

evilpuncker

vai se tratar garota
Messages
2,178
Points
0
Age
109
Location
bronzil
Github
EPuncker
Emulator
Client Version
2019-05-30a MAIN
I'm not that good regarding SQL queries so I'm here to ask something like:

if column xxxx exists on login table { execute sql query to add that column } end; (pseudocode)

PS: I know how to check if table exists but I'm kinda confused to do the same with columns

 
Last edited by a moderator:
You could use something with query_sql/query_logsql like:

Code:
query_sql("IF COL_LENGTH('table_name','column_name') IS NOT NULL BEGIN /*insert update query here*/ END");
 
not worked
default_sad.png


 
if(query_sql("select count(name) from syscolumns where id=(select id from sysobjects where name='table name')and name='column name'")){


}else{


}
 

 
what if my user doesn't have access to syscolumns and sysobjects?
default_tongue.png
I've seen several examples at google search but none worked :/ always syntax error
default_tongue.png
I've seen a npc at old eA forum that did the same thing that I'm trying to do but sadly can't find it anymore :/

 
what if my user doesn't have access to syscolumns and sysobjects?
default_tongue.png
I've seen several examples at google search but none worked :/ always syntax error
default_tongue.png
I've seen a npc at old eA forum that did the same thing that I'm trying to do but sadly can't find it anymore :/
you are right  , there is  a more simple  way to check

if(query_sql ("select column from `table`"))

 dispbottom "exist";

else

 dispbottom "not exist";

}

 
thanks my dear <3 but after creating the table it always throw an warning at map server

if(query_sql("select `stats` from `login`"))

[Warning]: script:query_sql: Too many columns, discarding last 1 columns.

 
thanks my dear <3 but after creating the table it always throw an warning at map server

if(query_sql("select `stats` from `login`"))

[Warning]: script:query_sql: Too many columns, discarding last 1 columns.
Haha ~
default_sleep.png
,  forgot to put array variable to save the select output

 
Last edited by a moderator:
Back
Top