Showing posts with label MySql. Show all posts
Showing posts with label MySql. Show all posts

Wednesday, November 14, 2012

Which Web Programming language to learn to keep you employed?

There are thousands of programming languages out there and have their own value over one and other. But there are a few programming languages which can keep you employed and you don't have to worry about earnings. Learning a right programming language on right time and right place is very necessary for your carrier. There are many examples out there who are not happy with their field and struggling in the market due to this fact. That's why I am going to share with my blog readers about the best programming languages and their scope in different areas of the world.
  • PHP
  • MySQL
  • Javascript
  • Perl
  • Ruby
  • Python
  • ASP.net

Monday, May 28, 2012

How to delete DUPLICATE records from MYSQL table

Some times we need to delete duplicate rows from a table. Because there is no need for keeping duplicate records in same table. Deleting these duplicate records is very easy. It can be don using some simple SQL queries.

Here’s two easy ways to clean out that table quickly.

1) Use ALTER IGNORE on MySQL 5.1+
MySQL will allow you to create a unique index on a table with duplicate records with its IGNORE SQL extension:

 ALTER IGNORE TABLE 'SHIPMENTS' ADD UNIQUE INDEX (CART_ID, TRACKING_NUMBER)  

Duplicates will be deleted.

2) Recreate the table with GROUP BY

 execute 'CREATE TABLE shipments_deduped like shipments;'  
 execute 'INSERT shipments_deduped SELECT * FROM shipments GROUP BY cart_id, tracking_number;'  
 execute 'RENAME TABLE shipments TO shipments_with_dupes;'  
 execute 'RENAME TABLE shipments_deduped TO shipments;'  
 add_index :shipments, [:cart_id, :tracking_number], :unique => true  
 execute 'DROP TABLE shipments_with_dupes;'  

Recreating the table is much, much faster than trying to delete the records in the existing table and doesn’t lock the existing table, making your application downtime minimal.

Insurance

Monday, April 30, 2012

How to resolve 1045 error when installing xamp

Some times whenever we install xamp on our system we get 1045 error in phpmyadmin. Here is the screen shot of that error,


I have found the solution of this error. Just un-comment // $cfg['Servers'][$i]['AllowNoPassword'] = TRUE; in phpmyadmin/config.inc.php file. Enjoyee....

Sunday, April 29, 2012

How to search within a defined radius using MySql and PHP

Hey guys, today my manager assigned me a task to search property listing withing a specific radius like within 10 km or 10 miles. I did it very easily because I have done this already in one of my project. But first time this task was very hard to do and I did a lot of research and goggled the internet to find out the solution. Well that is an old and long story. Today after doing my task I thought why not I post my work in the form of an article on my blog. So here is the article...

Monday, April 16, 2012

How to find first date and last date of month using php

Hi guys, i am going to share and very simple but very important function with you. In this post i am gonna show you how to find first date and last date of current month using php. Here are the two functions,

 <?php  
 function firstOfMonth()  
 {  
      return date("m/d/Y", strtotime(date('m').'/01/'.date('Y').' 00:00:00'));  
 }  
 function lastOfMonth()  
 {  
      return date("m/d/Y", strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))));  
 }  
 ?>  

PHP Date subtraction in hours, minutes, weeks formate

Some times we need to subtract two dates and we need the output in the form of months, weeks, hours and minutes etc. For doing to I wrote a function in php and i would like to share this with you guys...

 <?php  
 function create_time_range($start, $end, $by='30 mins')  
 {  
   $start_time = strtotime($start);  
   $end_time = strtotime($end);  
   $times = array();  
   for ( ;$start_time < $end_time; )  
   {  
     $times[] = $start_time;  
     $start_time = strtotime('+'.$by, $start_time);  
   }  
   $times[] = $start_time;  
   return $times;  
 }  
 // create array of time ranges  
 $times = create_time_range('00:00', '23:00', '30 mins');  
 // more examples  
 // $times = create_time_range('9:30am', '5:30pm', '30 mins');  
 // $times = create_time_range('9:30am', '5:30pm', '1 mins');  
 // $times = create_time_range('9:30am', '5:30pm', '30 secs');  
 // and so on  
 // format the unix timestamps  
 foreach ($times as $key => $time) {  
   $times[$key] = date('G:i', $time);  
 }  
 ?>