Re: Howto make a double LEFT JOIN

From: Date: Fri, 05 Oct 2001 14:50:14 +0000
Subject: Re: Howto make a double LEFT JOIN
References: 1 2 3 4 5 6 7  Groups: php.db 
Request: Send a blank email to php-db+get-13041@lists.php.net to get a copy of this message
Hello, > okay... 1<<table1.sid is leftshift the number 1 table1.sid times. > Your result will be a binary number... which will be the number 1 followed > by table1.sid 0's. Once you have this you do a bitwise or of all the > numbers you have shifted. This means any two rows where sid was the same > will be combined, as there is no difference between (1 or 1) and (1 or 0). > The last step, then, is to count the 1 bits and see how many different sid's > there were. > > Make Sense? The problem before was that there was no way to differentiate > one row from another, and thus no way to combine identical rows =P Oke, tnx, i understood > ACK! Don't do this. You do know that an unsigned int (using a signed int > in an auto_increment field is pointless anyway) has a max value of > 4294967295, right? To put this into perspective... if you had one million > customers, they would have more than 4294 transactions EACH before sid > filled up. If you are still worried about running out of numbers in your > sid field make it an unsigned bigint. The max value for an unsigned bigint > is 18446744073709551615... so that should give you lots of space to play in, Well, oke. I'm builing some pageviewcounter. Maybe count more then 1 million pageview a day in future :) You're right it will take many days before i have counted 18446744073709551615 views :). But in some way it feel like wasting. The first day using the first milion ids, the second day the next milion and never reuse that numbers. (Yes i realize 8bytes a row is much better then 32 (or 33 if you do stupid things :))) Maybe there is a better implemention? I dont i the first one solving this? -- every step i do: 1) creating a (1!) row id(unique)|........|time 2) deleting row(s) time<X -- > and sid will only be 8 bytes per row... not 33 (Also incidentally, if you do > want to save an md5 value to a row in the future... use char not varchar as > you know it will be 32 bytes and are adding a wasted 33rd byte). Oke, i see. > See my explanation above. All you are trying to do is shift a 1 digit to a > different place for each unique value of sid. The above definately won't > work if sid is an md5 value as md5 includes a-z characters. oke. > Again, hope that helps =) I will let you know Best regards, Bas

« previous php.db (#13041) next »