Sorting result explicitely in MySQL
Hello,
I you want to sort the result explicity & specify the order of which ‘order by’ comes back in,
like if you had a priority field that had the values “Low” “High” or “Medium” .. do this:
select * from tablename order by priority=’High’ DESC, priority=’Medium’ DESC, priority=’Low” DESC;
Another Smart way is :
SELECT * FROM tickets ORDER BY FIELD(priority, ‘High’, ‘Normal’, ‘Low’, ‘The Abyss’);
I observed that its not necessary to mention all the possible values.
e.g. The query we built was quit complex
SELECT b.mf_cocode,b.mf_schcode,b.mf_schname,b.grpcode,b.moptionname,b.mplanname
FROM
(SELECT c.mf_cocode,c.mf_schcode,c.mf_schname,c.grpcode,c.moptionname,c.mplanname
FROM mutual_category c
ORDER BY c.moptionname=’growth’ DESC,c.mplanname=’regular’ DESC) b
GROUP BY b.grpcode
Virtual Hosts
Hello Friends,
Today I implemented interesting concept called “Virtual Hosts”.
The Apache HTTP Server’s built in virtual hosting allows the server to provide different information based on which IP address, hostname, or port is being requested.
To activate name-based virtual hosting, uncomment the NameVirtualHost line by removing the hash mark (#) and replace the asterisk (*) with the IP address assigned to the machine.
Next, configure a virtual host by uncommenting and customizing the container.
On the line, change the asterisk (*) to the server’s IP address. Change the ServerName to a valid DNS name assigned to the machine, and configure the other directives as necessary.
To create a name-based virtual host, it is best to use the virtual host container provided in httpd.conf as an example.
The virtual host example read as follows:
#NameVirtualHost *:80
#
#
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#
Note :- The location of httpd.conf may vary as per server.
In my case, it was apache centos.
To activate name-based virtual hosting, uncomment the NameVirtualHost line by removing the hash mark (#) and replace the asterisk (*) with the IP address assigned to the machine.
Next, configure a virtual host by uncommenting and customizing the container.
On the line, change the asterisk (*) to the server’s IP address. Change the ServerName to a valid DNS name assigned to the machine, and configure the other directives as necessary.
To activate a newly created virtual host, the Apache HTTP Server must be reloaded or restarted.
E.g.
ServerAdmin preetul.correia@geo.com
DocumentRoot /home/preetul
sudo /etc/init.d/httpd restart
Ref : http://httpd.apache.org/docs/2.2/vhosts/
http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-apache-virtualhosts.html
Gratitude and Patience – story
THE APPLE !!
Once there was a small kid on earth. One fine day it came to know that god is distributing apples to humans in his place at heaven. The kid was so happy to receive that news and it went with lot of enjoyment to heaven to get the apple from god. There was a big queue standing to get apple from god and this kid also joined in that queue. While it was standing, it was fully excited and thrilled for the fact that it is going to receive in person from god’s hands. Its turn too came and the kid showed its both the hands to receive apple. God gave the apple but unfortunately the tiny hands couldn’t hold that big apple. Apple fell down and got wasted in mud. The kid got so disappointed. The ministers near the god informed that if the kid likes to have an apple from god again then it has to again follow the queue. Having waited for so long the kid didn’t want to return back to earth with empty hands so it decided to wait again in the queue.
This time the queue has become even longer than the previous one. While waiting in queue, the kid could see lot of people who returns back with apple in hands and utmost satisfaction on their faces. The kid was so much disappointed and thought why me alone didn’t get the apple in hand when all others were easily able to get it. What is the sin I did that I alone should suffer like this. Now the kid was so scared that it should not miss the apple again. Again its turn came and god gave the apple to the kid’s hands and after giving the apple god spoke to the kid.
“My dear child, last time after giving you the apple only I noticed the apple I gave to you was a rotten apple and that’s why I made that to fell down from your hands. Having given you a rotten apple, I felt bad for you and I wanted to give you the best apple in the farm and that time the best apple in the farm was growing and that’s why I made you to wait such a long time in the queue. Here it is. Now the apple that you have in hand is ‘The Best’ apple in the farm till to date. Enjoy.”
MORAL :
Friends, sometimes it so happens, as even after we put our 100% dedication and commitment things may get delayed or things may go wrong. Believe that god has something great for us and that’s why this has happened. Always say, ‘Gratitude & patience is absolutely the best way to bring more in one’s life’.
How smart is your right Foot…????
Hello frds,
I found some interesting fact through mail..
Just check it out…

Increase PHP memory limit
Hey,
I got error Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 13050 bytes) in my file /home/developer/Sachin/API/performance.php on line 227
You can view memory limit using
1. If your memory is set to 8M, continue with next step
2. Open your php.ini file. If your server is a Webune Dedicated Server with Redhat, Centos or Fedora, you can run the following command to edit the php.ini file:
3. VIM /etc/php.ini (you can view its location in phpinfo())
4. Code:
memory_limit = 64M ; Maximum amount of memory a script may consume (6MB)
5. Save the changes.
6. Restart Apache Server with the following command
Code:
/etc/init.d/httpd restart
7. Done
or
Youcan set the memory limit within a file using ini_set() function:
at ini_set(‘memory_limit’, ‘64m’); in your php page.
New Movies releae dates
My frnd Nilu, as for Release Date for Tum Mile(god knows why ppl are interested in such movies
), i googled to find it out.
Posting here for your reference.
# Release date of Tum Mile : November 13, 2009
# Release date of De Dana Dan : November 27, 2009
# Release date of Hook Ya Crook: December 11, 2009
# Release date of Prince It’S Showtime: December 11, 2009
# Release date of 3 Idiots : December 25, 2009
Cast : Aamir Khan, Kareena Kapoor, R Madhvan, Sharman Joshi
Music Director : Shantanu Moitra
My recommandation : Just Go for this movie.
I enjoyed the book “3 Mistakes…” and now dying to watch the movie. ![]()
# Release date of Kites : December 2009
# Release date of Rocket Singh – Salesman Of The Year: December 2009
# Release date of Season Greetings: January 1, 2010
# Release date of Rajniti: January 22, 2010
# Release date of Peter Gaya Kaam Se : February 12, 2010
# Release date of Paan Singh Tomar : February 26, 2010
# Release date of Phillum City: March 11, 2010
Info for persons Travelling in Auto Rickshaw in Mumbai
Good news for all those who had to travel in autos and also for those who had to bear all the nonsense’s of these autowallas.
We have already informed the traffic police about the problems which we used to face as daily commuters and they promised to arrange one of their people to Interface building between 6pm – 8pm.
Moreover request you to sit in the auto rickshaw without a word and ask them to take to your place and if at all they refuse to do the same kindly do not come out but whilst sitting in the auto immediately dial traffic control room’s number 24937755 / 24937746 / 24937747. Within 5 minutes the traffic police will reach and they can suspend auto rickshaw licenses.
Few Friends have tried yesterday and today from Malad station and it worked out…. If you are anywhere in Mumbai the above numbers will help you.
Source: http://www.taxguru.in/government-policy/info-for-persons-travelling-in-auto-rickshaw-in-mumbai.html
and
http://www.caclubindia.com/forum/messages/2009/2/26549_helpline_for_mumbai_auto_reckshaw_problem.asp?quote=151768&
BSNL Broadband connection
Hi Frds,
I have BSNL broadband connection at home.
Unfortunately my PC got formatted(due to virus
) & i lost my setup for the same.
I tries from side, googled also surf different blogs but everything failed. I lost more than tow days ![]()
Finally I have to pay Rs. 200 for the setup of broadband to a bsnl worker.
The setup is actually really simple and personally i don’t want to waste anybody’s time & money and hence putting it on blog.
The steps are as follows:
Start ->
Accessaries ->
Communications ->
New Connection Wizard ->
Continue Next ->
Connect to internet ->
Set up my connection manually ->
connect using broadband that requires username & password(PPoE) ->
Type ISP name(i.e. data1) ->
Type Internet account Information(i.e. given username & password)
Finish
& Your connection establish!!!!
Note:
1. The steps are for Windows XP(although ther must be same for all Windows OS)
2. Make sure that your DSL LED is stable.
If it not than you cannot establesh the connection.
Btw, I am using Modem provided by ITI(ADSL 2+)
MySQL Query Optimization – Indexing
Indexing is the most important tool you have for speeding up queries. Other techniques are available to you, too, but generally the one thing that makes the most difference is the proper use of indexes.
MySQL uses indexes in several ways:
* As just described, indexes are used to speed up searches for rows matching terms of a WHERE clause or rows that match rows in other tables when performing joins.
* For queries that use the MIN() or MAX() functions, the smallest or largest value in an indexed column can be found quickly without examining every row.
* MySQL can often use indexes to perform sorting and grouping operations quickly for ORDER BY and GROUP BY clauses.
* Sometimes MySQL can use an index to reading all the information required for a query. Suppose that you’re selecting values from an indexed numeric column in a MyISAM table, and you’re not selecting other columns from the table. In this case, when MySQL reads an index value from the index file, it obtains the same value that it would get by reading the data file. There’s no reason to read values twice, so the data file need not even be consulted.
Ref:- http://www.informit.com/articles/article.aspx?p=377652

Recent Comments