perform inner join on same table in mysql

During application development, i was stuck in one mysql – query problem.  i don’t know whether this post title gives meaning or not. but I had used this title to search on google for my problem’s solution.  so i kept same here.

let me describe problem

| switch                  | port_no |
| 00:00:00:00:00:00:00:02 | 3       |
| 00:00:00:00:00:00:00:01 | 2       |
| 00:00:00:00:00:00:00:01 | 1       |
| 00:00:00:00:00:00:00:02 | 1       |
| 00:00:00:00:00:00:00:04 | 2       |

so i have such type of data in sla table.  and i want bellow output

Expected output

| switch                  | port_no |
| 00:00:00:00:00:00:00:02 | 3,1     |
| 00:00:00:00:00:00:00:01 | 2,1     |
| 00:00:00:00:00:00:00:04 | 2       |

so here is magic function which saved my life 🙂

Function :


Query which return expected output

select switch,GROUP_CONCAT(port_no) from sla group by switch;

i know lots of newbie developers got such problem so i’m sharing here..
if anyone have best title for it .. plz suggest it in comment.



REST Client Example in Ruby

REST Client – simple DSL for accessing HTTP and REST resources

A simple HTTP and REST client for Ruby, inspired by the Sinatra’s microframework style of specifying actions: get, put, post, delete.

I found this Ruby-Gem very useful while building App. so i will describe here how to use REST Client in Ruby

Simple example for REST Client POST Request.

require 'rest_client' 'http://localhost:8080/wm/test/json', params.to_json, :content_type => :json, :accept => :json
result = JSON.parse(res)
return result.to_json

above example send post request to my local server, which takes few parameters in form of json and


return output in form of JSON.

likewise, you can use any method GET,PUT,DELETE.

Hope you’ll like dis 🙂

Posting JSON data to sinatra with JQuery

I guess this post is mainly useful when you want to build Restful API with Sinatra.   Let’s say you want to pass JSON data to Sinatra backend using JQuery. so you may got very first question is How to parse JSON POST Data in Sinatra rest api ?  am i right ?

so here is full example which demonstrate how to send JSON data to Sinatra REST API.

JQuery Code:

url: '/test_api',
type: 'POST',
dataType: 'json',
contentType: "application/json",
success: function(data){

let’s say data (json variable) contain complex data like

"topo": [
      "dpid": "00:00:00:00:00:00:00:03",
      "ports": [
"app": "vm_migration"

Ruby Sinatra Rest Function

post '/test_api', :provides => :json do
     # bellow line get post json data
     params = JSON.parse(request.env["rack.input"].read) 
     # you can access key value like bellow
     app = params["app"]
     params["topo"].each do |topo|
            dpid = topo["dpid"]
            # getting each value of key using each
            topo["ports"].each do |port| 
                #Process Data
  rescue Exception => e
    return e.message

Hope it is useful..  plz do comment if it is useful for you..

any question related to post, feel free to ask.

Getting started with NodeJS


Please read this to get basic information about node js. don’t like to write too much..

About me

How to install ?

You can google it.. or else I got one link please refer this.

let me go with basic example which is also given there in about me section. nodejs is really helpful for building a scalable network programs.

Basic Echo Server

var http = require('http');
var s = http.createServer(function(req,res){
	res.end("hello word");

woow..  few lines of code and we’ve done with basic server..  🙂

Run :

use bellow command to run this app

node basic_server.js

Fire request on our server

1) using curl : curl http://localhost:8000

2) using url : http://localhost:8000 (in browser)

Network Information API

How to detect Network Connection changes ??

Do you have same question sometime in ur mind ? hmm.. i got answer from MDN

This API provides information about the system’s connection, such as connection bandwidth of user device, or whether the connection is metered.

Usage :
This can be used to select hight definition and low definition content based on the user’s connection.

Detecting connection changes

var connection = navigator.connection || navigator.mozconnection 
|| navigator.webkitconnection;
function updateConnectionStatus(){
alert("connection bandwidth="+connection.bandwidth +"Mbs");
alert("the connection is metered");

Simple JS Code ..!!@@

How to get the facebook details using id?

Hello guys,

Today I gonna explain you how to get Facebook user’s basic detail using user id. bellow function useful when you are developing authentication system of your site using facebook so there you need basic detail of your visitor.


function getUserInfo(id)
	type: "GET",
	url: ""+id,
	contentType: "application/json; charset=utf-8",
	dataType: "json",
	success: function(data) {

That’s it.. isn’t it simple… 🙂