Help to fix long MYSQL
#7

Quote:
Originally Posted by [DOG]irinel1996
Посмотреть сообщение
Why don't you save all these things like a text and split them with sscanf on loading? Believe me, it's easier and the query will be shorter also.

http://forum.sa-mp.com/showthread.ph...98#post1087498
Absolutely NOT. This is against first normal form and defeats the purpose of using a database. It doesn't allow for grouping or counting or properly using where. Never do that. Never settle for what is easy but do what is right.

@OP, I think you've been told at least half a dozen (by me and others) that you should normalize your tables. If you need to add a number to a column name you are doing databases wrong.

Faction has Members and has Cargo. All words that I have underlined constitute different tables.

Very rudimentary you would have four tables that look like this. Columns that are underlined are part of that table's primary key.

Faction (existing table)


Player (existing table)


FactionMember (new table)


FactionCargo (new table)



FactionMember (and by extension FactionCargo) would then be filled as follows:


Or in more useful format:
PHP код:
SELECT f.name AS factionNamep.name AS playerNameFROM_UNIXTIMEjoinedDate ) AS joinedDaterank
FROM FactionMember fm
JOIN Player p ON p
.id fm.playerId
JOIN Faction f ON f
.id fm.factionId 
Produces:
Reply


Messages In This Thread
Help to fix long MYSQL - by luccagomes15 - 20.10.2015, 18:28
Respuesta: Help to fix long MYSQL - by [DOG]irinel1996 - 20.10.2015, 22:37
Re: Respuesta: Help to fix long MYSQL - by luccagomes15 - 21.10.2015, 01:29
Re: Respuesta: Help to fix long MYSQL - by Kevln - 21.10.2015, 02:12
Re: Respuesta: Help to fix long MYSQL - by luccagomes15 - 21.10.2015, 03:05
Re: Respuesta: Help to fix long MYSQL - by Kevln - 21.10.2015, 03:29
Re: Respuesta: Help to fix long MYSQL - by Vince - 21.10.2015, 09:27
Re: Help to fix long MYSQL - by AbyssMorgan - 25.10.2015, 07:06
Re: Help to fix long MYSQL - by luccagomes15 - 25.10.2015, 14:51
Re: Help to fix long MYSQL - by luccagomes15 - 25.10.2015, 14:53

Forum Jump:


Users browsing this thread: 1 Guest(s)