evilpuncker 503 Posted August 9, 2013 (edited) 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 Edited August 9, 2013 by evilpuncker Quote Share this post Link to post Share on other sites
0 Mumbles 193 Posted August 10, 2013 You could use something with query_sql/query_logsql like: query_sql("IF COL_LENGTH('table_name','column_name') IS NOT NULL BEGIN /*insert update query here*/ END"); Quote Share this post Link to post Share on other sites
0 evilpuncker 503 Posted August 10, 2013 not worked Quote Share this post Link to post Share on other sites
0 Angelmelody 221 Posted August 10, 2013 if(query_sql("select count(name) from syscolumns where id=(select id from sysobjects where name='table name')and name='column name'")){}else{} Quote Share this post Link to post Share on other sites
0 evilpuncker 503 Posted August 10, 2013 what if my user doesn't have access to syscolumns and sysobjects? I've seen several examples at google search but none worked :/ always syntax error 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 :/ Quote Share this post Link to post Share on other sites
0 Angelmelody 221 Posted August 10, 2013 what if my user doesn't have access to syscolumns and sysobjects? I've seen several examples at google search but none worked :/ always syntax error 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"; } 1 evilpuncker reacted to this Quote Share this post Link to post Share on other sites
0 evilpuncker 503 Posted August 10, 2013 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. Quote Share this post Link to post Share on other sites
0 Emistry 145 Posted August 10, 2013 if(query_sql("select `stats` from `login`",.@stats)) try 1 evilpuncker reacted to this Quote Share this post Link to post Share on other sites
0 evilpuncker 503 Posted August 10, 2013 thank you all, issue solved! Quote Share this post Link to post Share on other sites
0 Angelmelody 221 Posted August 11, 2013 (edited) 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 ~ , forgot to put array variable to save the select output Edited August 11, 2013 by Angelmelody Quote Share this post Link to post Share on other sites
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
Edited by evilpunckerShare this post
Link to post
Share on other sites