[SQL] encryption/decryption

2006-04-01 Thread AKHILESH GUPTA
hi all,
just to ask u all one thing regarding encryption/decryption.

i am migrating my database from mysql to pgSQL using a php script.
in mysql there is a table 'users' where a field 'password' is there of type varchar(30),
and is encrypted using AES algorithm, and when i check all the records in mysql it looks like:-

mysql> select * from USERS;
++--+--+---++---+
| id | name |
password |
password_modified | created_on | admin |
++--+--+---++---+
|  1 | Admin    | \u\u\u6fde\u\u
   
\u/|\u9A |
Y
| 2005-08-10 | Y |
|  2 | sangeeta |
\u\uX\u\u\u0215\u0635\ukg\ug\u |
Y
| 2005-08-13 | Y |
|  3 | check1   |
[EMAIL PROTECTED] |
Y
| 2005-08-10 | Y |
|  4 | check2  
| 
|
Y
| 2005-08-10 | N |
|  5 | check3   |
V[6\u\u\uw\u\u\u\u.C'\u |
Y
| 2005-08-10 | N |
| 16 | user |
5\u\u\u\u<\u.\u\u\u\u^k |
Y
| 2005-08-10 | N |
|  6 | admin    |
\u77\u\u\us\u\u3h\uM\u%\u |
Y
| 2005-08-10 | Y |
| 17 | anita    |
\u\u\u\u\u\uH\u"\uhe)U\u |
Y
| 2005-09-27 | Y |
|  1 | Akhilesh |
cheeks   |
y
| 2006-04-01 | y |
++--+--+---++---+
9 rows in set (0.00 sec)
(all these "ufff\ufff\ufff<\ufff\U\ufff" the
password field is seems as special characters like triangles and
rectangles, u can say like chinese characters)

now, when i am running my script, then only one record, where
name='check2' is copied (because no password is there in this case),
but not any other record is displayed.

plz help me in this case and do tell what should i do to copy all the records...
(any suggestion either at the php/mysql/postgresql level)
do help me..plz..!-- Thanks & Regards,AkhileshDAV Institute of ManagementFaridabad(Haryana)GSM:-(+919891606064)  (+911744293789)"FAILURES CAN BE FORGIVEN BUT AIMING LOW IS A CRIME"


[SQL] cross tables, SELECT expressions, and GROUP BY problem

2006-04-01 Thread Ross Johnson
Hi,

I'm relatively stretched when it comes to SQL but I'm getting there. I
have a question though:

Thanks to various web sites I've succeeded in creating simple cross
tables in PostgreSQL. I'm now trying more complicated examples
(migrating queries from MS Access to PostgreSQL). I'm stuck on getting
grouping to work where the selection element isn't a real table field,
where it is generated by a CASE statement. Here's a full actual SELECT
statement, that works but isn't quite what I need, followed by the first
few rows of output:

SELECT DISTINCT
CASE
WHEN lower(c."Order") = 'coleoptera' THEN 5
WHEN lower(c."Order") = 'trichoptera' THEN 8
WHEN lower(c."Order") = 'ephemeroptera' THEN 6
WHEN lower(c."Order") = 'plecoptera' THEN 7
WHEN lower(c."Class") = 'oligochaeta' THEN 1
WHEN lower(c."Family") LIKE 'chiron%' THEN 2
WHEN lower(c."Order") = 'diptera' AND lower(c."Family") NOT 
LIKE 'chiron%' THEN 3
ELSE 4
END AS "Ranking",
CASE
WHEN lower(c."Order") = 'coleoptera' THEN 'Coleoptera'
WHEN lower(c."Order") = 'trichoptera' THEN 'Trichoptera'
WHEN lower(c."Order") = 'ephemeroptera' THEN 'Ephemeroptera'
WHEN lower(c."Order") = 'plecoptera' THEN 'Plecoptera'
WHEN lower(c."Class") = 'oligochaeta' THEN 'Oligochaeta'
WHEN lower(c."Family") LIKE 'chiron%' THEN 'Chironomidae'
WHEN lower(c."Order") = 'diptera' AND lower(c."Family") NOT 
LIKE 'chiron%' THEN 'Diptera (Other)'
ELSE 'Other'
END AS "Taxa",
SUM(CASE WHEN b."LocationCode" = '011' THEN c."Count" END) AS 
"011",
SUM(CASE WHEN b."LocationCode" = '012' THEN c."Count" END) AS 
"012",
SUM(CASE WHEN b."LocationCode" = '013' THEN c."Count" END) AS 
"013",
SUM(CASE WHEN b."LocationCode" = '014' THEN c."Count" END) AS 
"014"
FROM "tblBugIDSheetInfo" b
INNER JOIN "tblBugCount" c USING ("BugSheetID")
GROUP BY c."Order", c."Class", c."Family"
ORDER BY "Ranking"

Generates the following output:

Ranking Taxa011 012 013 014
---
1   "Oligochaeta"   487 171117591078
1   "Oligochaeta"   7   
1   "Oligochaeta"   
2   "Chironomidae"  1385233515001513
2   "Chironomidae"  
3   "Diptera (Other)"   5
3   "Diptera (Other)"   1   1   3
3   "Diptera (Other)"   199 19  40  37
3   "Diptera (Other)"   
...

I want to GROUP on the "Ranking" field as well so that all rows with the
same "Ranking" value are SUMmed. That is, I'm trying to achieve the
following:

Ranking Taxa011 012 013 014
---
1   "Oligochaeta"   494 171117591078
2   "Chironomidae"  1385233515001513
3   "Diptera (Other)"   199 20  41  45
...

I tried including "Ranking" at the head of the GROUP BY list, but it has
no effect.

Can anyone show me what I'm doing wrong and/or show me what I need to
change? I'd rather avoid wrapping the whole query in another SELECT that
would duplicate this one, assuming that that would work.

Thanks.
Ross Johnson

PS. I just want to acknowledge the very useful web sites that I found
via google which helped out considerably getting me this far with cross-
tables. The above query is based on this one:

http://dev.mysql.com/tech-resources/articles/wizard/print_version.html



---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster