[SQL] 1-byte integers

2004-09-18 Thread stig erikson
how can i specify an integer to be one byte byte or even 4 bits long?
int1, int(1), tinyint are nowhere to be seen.
smallest i can find is smallint that is 2 bytes.
in a table i will have a few columns with values between 0 and 15, so 
optimally i am looking for some kind of  unsigned 4-bits, or (un)signed 
integer (1-byte).

i can live with smallint for a while but estimate a few millions of rows 
in the table to be a reality soon, in such cases every byte matters.

is there some
stig
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
   (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [SQL] A Not Join

2005-11-26 Thread stig erikson
L van der Walt wrote:
> I have three table:
> Users - Contains username, ID etc...
> Permissions - A permission name and ID
> Link up table - The user.id and permission.id
> 
> If a user.id and a permission.id row exists in the linkuptable the user
> have that permission granted.
> 
> With the statement below I can see the permissions a user have.
> 
> SELECT users.username, permissions.name
> FROM users INNER JOIN linkuptable
>  ON (users.id = linkuptable.userid)
> INNER JOIN permissions
>  ON (permissions.id = linkuptable.permissionid)
> WHERE users.username = 'DummyUser'
> 
> How do I see the permissions that user DON'T have with a fast SQL
> statement.
> 
> Thus, a NOT the statement for the above SQL statement
> 
> Regards
> 
> Lani
> 

what you need to do is select all possible permissions and then remove the
permissions that exist. try somthing like:

SELECT permissions.name
FROM permissions.name
WHERE permission.permissionid NOT IN
( SELECT permissions.permissionid
  FROM users INNER JOIN linkuptable
  ON (users.id = linkuptable.userid)
  INNER JOIN permissions
  ON (permissions.id = linkuptable.permissionid)
  WHERE users.username = 'DummyUser'
)


---(end of broadcast)---
TIP 6: explain analyze is your friend


[SQL] a celko-puzzle from long time ago

2006-11-06 Thread stig erikson

While reading celko's SQL puzzles (second edition) i followed a reference to 
http://www.dbmsmag.com/9801d06.html.
There is a puzzle that counts items in boxes.
When i try to run the proposed solution on PG 8.1.5, PG says: ERROR:  column reference 
"qty" is ambiguous


apparently the variable declaration used in the solution is not proper for 
PostgreSQL. Is there a way to solve this puzzle in PostgreSQL?

/stig

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq