Adding new tables in SQL
#8

Your table:
Код:
CREATE TABLE IF NOT EXISTS `account_data` (

	`ID` INT(24) NOT NULL AUTO_INCREMENT,
	`Password` VARCHAR(129) NOT NULL,
	`IP` VARCHAR(16) NOT NULL,
	`Admin` INT(4) NOT NULL,
	`VIP` INT(2) NOT NULL,
	`Money` INT(24) NOT NULL,
	`PosX` FLOAT(24) NOT NULL,
	`PosY` FLOAT(24) NOT NULL,
	`PosZ` FLOAT(24) NOT NULL,
	`PosA` FLOAT(24) NOT NULL,
 
	PRIMARY KEY(`ID`)
) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT = 1;
PHP код:
mysql_format(mysqlquerysizeof(query), "INSERT INTO account_data (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `PosA`) VALUES ('%e', '%e', '%e', 0, 0, 0, %f, %f, %f, %f)"playernameAccount[playerid][Password], playeripSTART_XSTART_YSTART_ZSTART_A);
mysql_tquery(mysqlquery"OnAccountRegister""i"playerid); 
Best is to add default values to columns that have a non-constant value upon creating a row. Columns such as: Admin, VIP, Money, PosX to PosZ all have constant values when you create the player's row.

Your table would look like so:
Код:
CREATE TABLE IF NOT EXISTS `account_data` (

	`ID` INT(24) NOT NULL AUTO_INCREMENT,
	`Password` VARCHAR(129) NOT NULL,
	`IP` VARCHAR(16) NOT NULL,
	`Admin` INT(4) NOT NULL DEFAULT '0',
	`VIP` INT(2) NOT NULL DEFAULT '0',
	`Money` INT(24) NOT NULL DEFAULT '0',
	`PosX` FLOAT(24) NOT NULL DEFAULT '2492.0830',
	`PosY` FLOAT(24) NOT NULL DEFAULT '-1665.6895 ',
	`PosZ` FLOAT(24) NOT NULL DEFAULT '13.3438',
	`PosA` FLOAT(24) NOT NULL DEFAULT '93.1757',
 
	PRIMARY KEY(`ID`)
) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT = 1;
And your query would then result into:
PHP код:
mysql_format(mysqlquerysizeof(query), "INSERT INTO account_data (`Name`, `Password`, `IP`) VALUES ('%e', '%e', '%e')"playernameAccount[playerid][Password], playerip);
mysql_tquery(mysqlquery"OnAccountRegister""i"playerid); 
Reply


Messages In This Thread
Adding new tables in SQL - by eikzdej - 01.04.2016, 23:47
Re: Adding new tables in SQL - by eikzdej - 02.04.2016, 11:48
Re: Adding new tables in SQL - by AndySedeyn - 02.04.2016, 11:56
Re: Adding new tables in SQL - by Barnwell - 02.04.2016, 13:58
Re: Adding new tables in SQL - by eikzdej - 02.04.2016, 16:04
Re: Adding new tables in SQL - by AndySedeyn - 02.04.2016, 18:08
Re: Adding new tables in SQL - by eikzdej - 03.04.2016, 00:22
Re: Adding new tables in SQL - by AndySedeyn - 03.04.2016, 09:15

Forum Jump:


Users browsing this thread: 3 Guest(s)