Portal SAMP
[Ajuda] Verifcar se a coluna existe na tabela - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] Verifcar se a coluna existe na tabela (/showthread.php?tid=1623)



Verifcar se a coluna existe na tabela - Pure Revenge - 10/09/2021

Como eu verifico isso?
Tipo, eu fiz um para checar se existe alguma linha em uma coluna de uma tabela
Código:
new query[SQL_FORM_LENGTH], Cache:result, rows;
mysql_format(MySQL:connectionhandle, query, sizeof(query),"SELECT * FROM `Contas` WHERE `nickname`='%s' ", PlayerName(playerid));
result = mysql_query(MySQL:connectionhandle, query);
cache_get_row_count(rows);
cache_delete(result);
if(rows > 0) print("O nickname ja esta registrado!");
else print("O nickname nao esta registrado!");
Mas não sei como fazer para checar se essa coluna tambem existe
Uma luz ?


RE: Verifcar se a coluna existe na tabela - mau.tito - 10/09/2021

Bom dia Prezado,

Posso ter entendido errado mas deve ser isso que você esta querendo.

CREATE TABLE IF NOT EXISTS

Att,


RE: Verifcar se a coluna existe na tabela - Dr Editor - 10/09/2021

https://stackoverflow.com/questions/3395798/mysql-check-if-a-column-exists-in-a-table-with-sql