Multiple lines
Hey, is it possible to make a SQL Statement with multiple lines like I've got SQL like this:
IP, Name, Auth, Country, Privileges.. So instead of this: CREATE TABLE IF NOT EXISTS players (IP varchar(32), Name varchar(32), Auth varchar(32), Country varchar(3), Privileges int(2), PRIMARY KEY ( IP )) How can I do something like this: CREATE TABLE IF NOT EXISTS players ( IP varchar(32), Name varchar(32), Auth varchar(32), Country varchar(3), Privileges int(2), PRIMARY KEY ( IP )) So it will be easier to understand because of my SQL has over 30 columns. |
Re: Multiple lines
Use the \ and \ split line technique:
Code:
new const szQuery[] = "CREATE TABLE IF NOT EXISTS players (\ |
Re: Multiple lines
Ok thank you ! And one more question, if there is INT(2) what is the maximum number I can enter there ? I mean the character number. it's up to 2 characters yea ?
1. is it better to work with one big SQL or 2 smaller ones ? But If I will work with multiple it will be harder to work I think :) 2. What does NOT NULL stands for ? whats the difference : Name varchar(32) and Name varchar(32) NOT NULL 3. If I use `PRIMARY KEY ( IP )` Then later how should I use SQL_ReadResult(Query, 0); I've ID before IP like this: Quote:
|
Re: Multiple lines
INT(2) is kinda wrong, INT can hold up to 10, so, you can use TINYINT(2), it's from -128 to 127 or 0 to 255 unsigned.
More info: http://dev.mysql.com/doc/refman/5.0/en/data-types.html EDIT: It's better to use more smaller tables, yes it's harder but it should be faster for the SELECT. NOT NULL is not null =) to be more explicit, if a column doesn't have "NOT NULL" it automatically sets the value to NULL if nothing is specified there when inserted... if you know you'll specify *all* columns you should use NOT NULL because it's a waste of space to use that null. PRIMARY() doesn't affect the order of results, the order you SELECT them does. PRIMARY() just sets it as index, unique and I think it has something to do with auto increment, I think it's required for it. |
Re: Multiple lines
Well I've got Ban, Rank and Admin system on one SQL :D I don't know how to properly work with many SQL's and it's way harder to use INNER JOIN and such stuff.
|
Re: Multiple lines
Ban, rank and admin stuff shouldn't occupy 30 columns O.o
Btw, if you're going to get them anyway, it's ok to just use one big table... but if they're optional you should consider separate tables. |
Re: Multiple lines
Ok thank you, but what for PRIMARY KEY is used ? ?
Also when it exceeds 18 lines it gives me error like this: Error: Input line too long (after substitutions) on line 33 Error: Invalid string (possibly non-terminated string) on line 34 I've deleted 1 line and now it compiles, that szQuery has 451 characters. |
Re: Multiple lines
format it
PHP Code:
|
| All times are GMT -4. The time now is 19:31. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.