Audit/Normalized MySQL Query

From MicroFocusInternationalWiki
Jump to: navigation, search

Here is the query I use to normalize dates and IP addresses in my audit queries -

select FROM_UNIXTIME(ClientTimestamp) ClientTimeStamp,inet_ntoa(SourceIP + pow(2,32)) SourceIP,ClientMS,
FROM_UNIXTIME(ServerTimestamp) ServerTimestamp,SessionID,Component,EventID,Severity,Grouping,Originator,OriginatorType,
Target,TargetType,SubTarget,Text1,Text2,Text3,Value1,Value2,Value3,MIMEType,DataSize,Data,Signature from 
<database>.<table> where <somecriteria>;

This can be helpful when querying data from PHP/PERL, because you don't need to worry about converting dates or IP addresses into a readable format. Obviously it can be modified so only the columns you need show up in your resultset.