Posts tagged mysql
Converting Rows to Columns in SQL
Jan 5th
There was this table,
ORG_ID LEGACY_ORG_CODE ------ ------------------ 1001 8909 1001 12323 1002 80909 1002 78798 1002 09009
and the requirement was to get the concatenated legacy_org_code like
ORG_ID LEGACY_ORG_CODE ------ ------------------ 1001 8909, 12323 1002 80909, 78798, 09009
The solution to this is:
SELECT PL.ORG_ID, (SELECT LEGACY_ORG_CODE + ',' FROM SGT_ORG_PLAN ORGPL WHERE ORGPL.ORG_ID = PL.ORG_ID ORDER BY LEGACY_ORG_CODE FOR XML PATH('')) AS ORG_CODE FROM SGT_ORG_PLAN PL GROUP BY PL.ORG_ID
I was looking for simple answers on the web I came across this link, that helped me to get it done in a simple SQL statement. Recording it here for future reference. This technique is called Blackbox XML.
Uninstalling MySQL on Mac OS X
Jan 1st
Installing LAMP in Ubuntu
Apr 27th
Following are the steps to get Apache, MySQL and PHP installed on a Ubuntu system.
Installing Apache:
In the terminal window issue the following command
1 |
sudo apt-get install apache2 |
To test if Apache has installed successfully, open a browser and browse to http://localhost. A message “It works” will be displayed.
Installing PHP
In the terminal window issue the following command
1 |
sudo apt-get install php5 libapache2-mod-php5 |
Once the installation is complete, to get php working, restart apache server by issuing the following command
1 |
sudo /etc/init.d/apache2 restart |
To test that PHP has been successfully installed, quickly create a test PHP script
1 |
sudo gedit /var/www/test.php |
In the gedit window, type a script and save the file
Open up a browser window and open the test.php file created. The PHP application environment information will be displayed.
Installing MySQL
In the terminal, run the following command
1 |
sudo apt-get install mysql-server |
That should get mysql installed. You will be prompted for a ‘root’ db user password. Enter it.
To test mysql, in the terminal issue,
1 |
mysql -u root -p |
Enter the root user password for mysql server. You will be launched into the mysql prompt.
Installing phpMyAdmin
To install phpMyAdmin, issue the following command at the terminal
1 |
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin |
To test phpmyadmin, open a browser and navigate to http://localhost/phpmyadmin.
Thats it!
