This is just a simple SQL statement that lists your 10 most commented WordPress articles: SELECT p.ID, p.post_title, count(comment_ID) AS num_comments FROM wp_posts p, wp_comments c WHERE p.ID=c.comment_post_ID GROUP BY p.ID, p.post_title ORDER BY num_comments DESC LIMIT 0,10;
Migrating an existing Scuttle database to SemanticScuttle
I’ve migrated my existing bookmark collection from Scuttle to SemanticScuttle. All it took was these three lines of SQL: INSERT INTO semanticscuttle.sc_users (uId,username,password,uDatetime,uModified,name,email,homepage,uContent) (SELECT * FROM scuttle.sc_users); INSERT INTO semanticscuttle.sc_bookmarks (bId,uId,bIp,bStatus,bDatetime,bModified,bTitle,bAddress,bDescription,bHash) (SELECT * FROM scuttle.sc_bookmarks); INSERT INTO semanticscuttle.sc_bookmarks2tags (SELECT * FROM scuttle.sc_tags);
Oracle: SELECT top N rows skipping the first X rows
Apparently, it is not possible to use Oracle’s pseudo column rownum to select rows after a given number of rows, e.g. like SELECT * FROM tab WHERE rownum > 100; or in MySQL SELECT * FROM tab LIMIT 100,50; Oracle’s explanation for this (from the DB reference: ROWNUM): The first row fetched is assigned a [...]
Oracle: How to call a function from the SQL*Plus command line
If you would like to verify the result of a function call in Oracle SQL*Plus you could simply include it in a SQL select statement like this: CREATE OR REPLACE FUNCTION testfunction(testparm IN NUMBER) RETURN NUMBER IS BEGIN RETURN(testparm); END testfunction; SQL> select testfunction(123) from dual; TESTFUNCTION(123) —————– 123 SQL>
SQL command for killing Oracle user sessions
Here’s a small piece of SQL to generate SQL commands for killing all user sessions of a given user (you need to be sys/system): select ‘alter system kill session ”’ || sid || ‘,’ || serial# || ”’;’ from gv$session where username=’USER’ and machine=’PCNAME’;
PowerShell: Zugriff auf MySQL-Datenbank
Mit der PowerShell auf eine MySQL-Datenbank zuzugreifen ist eigentlich recht einfach, da vorhandene .NET-Klassen in der PowerShell verwendet werden können. Man benötigt nur die entsprechenden Klassen für den MySQL-Zugriff. Das ist in meinem Fall der MySQL Connector/Net 5.1. Die früheren Versionen funktionieren mit meiner Datenbank nicht (MySQL-Version 5.0): Error connecting to the server: Unable to [...]
title-Feld der Frontend Usergroups in TYPO3 verlängern
Bin gerade auf ein kleines Problem bei der Entwicklung meiner TYPO3-Extension gestoßen. Ich wollte ja die Frontend Usergroups als Speicherort für die Abteilungen des Unternehmens nutzen und nun ist mir aufgefallen, dass die maximale Länge der Bezeichnung einer solchen Gruppe 20 Zeichen beträgt. Nicht gerade viel für eine aussagekräftige Abteilungsbezeichnung. Doch wie gut, dass dieses [...]
TYPO3 Extension: Frontend Benutzer einer bestimmten Gruppe ermitteln
Wer sich ein bisschen in die Datenbankstruktur von TYPO3 eingearbeitet hat, merkt sehr schnell, wie seltsam die Zuordnung von Benutzern (Frontend sowie Backend) zu ihren Benutzergruppen gelöst ist. Anstatt über eine “vernünftige” M-zu-N-Tabelle, werden die Benutzergruppen den Benutzern über das Feld usergroup in fe_users bzw. be_users zugewiesen. Dieses Feld ist aber nicht ohne Weiteres editierbar [...]



