Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z8RRs-0005Mq-Im for pgsql-admin@arkaria.postgresql.org; Fri, 26 Jun 2015 11:05:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Z8RRq-0006CU-Ex for pgsql-admin@arkaria.postgresql.org; Fri, 26 Jun 2015 11:05:30 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z8RPc-0004KN-I5 for pgsql-admin@postgresql.org; Fri, 26 Jun 2015 11:03:12 +0000 Received: from cmailc.vita.virginia.gov ([166.67.65.183]) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1Z8RPU-0003ib-O6 for pgsql-admin@postgresql.org; Fri, 26 Jun 2015 11:03:10 +0000 X-SBRS: None X-HAT: Group: RELAYLIST_WHITELIST, Policy: $RELAYED_WHITELIST X-IronPort-AV: E=Sophos;i="5.13,684,1427774400"; d="scan'208,217";a="139526302" Received: from unknown (HELO COVMSGCES-HUB02.cov.virginia.gov) ([10.192.2.218]) by CRelayC.vita.virginia.gov with ESMTP/TLS/AES128-SHA; 26 Jun 2015 07:03:02 -0400 Received: from COVMSGCES-MBX01.cov.virginia.gov ([10.192.2.206]) by COVMSGCES-HUB02.cov.virginia.gov ([10.192.2.218]) with mapi id 14.03.0181.006; Fri, 26 Jun 2015 07:03:02 -0400 From: "Burgholzer, Robert (DEQ)" To: "pgsql-admin@postgresql.org" Subject: Re: select query of mysql to postgres Thread-Topic: [ADMIN] select query of mysql to postgres Thread-Index: AQHQr+hUoB0cwQk160aGGsmP6hGAPZ2+no9e Date: Fri, 26 Jun 2015 11:03:01 +0000 Message-ID: <77F5F8FA4B407F43BFCFD3FC3478969108EC9201@COVMSGCES-MBX01> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.193.11.61] Content-Type: multipart/alternative; boundary="_000_77F5F8FA4B407F43BFCFD3FC3478969108EC9201COVMSGCESMBX01_" MIME-Version: 1.0 X-Pg-Spam-Score: -5.6 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org --_000_77F5F8FA4B407F43BFCFD3FC3478969108EC9201COVMSGCESMBX01_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Two things - 1) Off the top of my head I would guess that the "@" symbols r= efer to something that is mysql specific (or in my limited postgresql exper= ience, I have not seen/used it), 2) you should include an error message, ca= use that will tell you what type of error and approximate location, 3) to g= et help on this it may help other people if you formatted your query in a w= ay that was more legible. For example: select bs.toll_zone, bs.toll_fee, concat(r.route_number,if(r.route_direction=3D'UP','UP','DN')) route_numbe= r, route_order, r.route_id, ifnull(bs.bus_stop_code, bs.bus_stop_id) bus_stop_code, ifnull(bs.bus_stop_name, '') bus_stop_name, (ifnull(bs.bus_stop_name_nudi, '')) bus_stop_name_nudi, bs.bus_stop_id, ifnull(bs.alias1, '') alias1, IF( if(ifnull(rm.schedule_distance, 0)=3D'0',ifnull(rm.distance, 0),ifnul= l(rm.schedule_distance, 0)) IS NULL, @tot_dur :=3D @tot_dur, @tot_dur :=3D = @tot_dur + if(ifnull(rm.schedule_distance, 0)=3D'0',ifnull(rm.distance, 0),= ifnull(rm.schedule_distance, 0)) )/1000 AS tot_dist, ifnull(rp.sub_stage,'N= ') sub_stage, ifnull(rp.fare_stage,'N') fare_stage,a.stage_count, rmd.adult= , rmd.children, rmd.senior_citizenfrom route r JOIN (SELECT @tot_dur :=3D 0= ) d inner join route_point rp on rp.route_id =3D r.route_id inner join bus_= stop bs on bs.bus_stop_id=3Drp.bus_stop_id and bs.point_type_id!=3D2 left j= oin route_map rm on rm.start_bus_stop_id=3Drp.bus_stop_id and rp.route_id= =3D'3004' and rm.route_id=3D'3004' INNER JOIN (select route_id, route_point= s_id, if(if(rp.fare_stage=3D'Y',1,0) IS NULL,@stage_count :=3D @stage_count= ,@stage_count :=3D @stage_count+if(rp.fare_stage=3D'Y',1,0)) as stage_count= from route_point rp JOIN (SELECT @stage_count :=3D 0) e where rp.route_id= =3D'3004' ) aON rp.route_points_id =3D a.route_points_id INNER JOIN rate_ma= ster_details rmd ON a.stage_count =3D rmd.stage_no AND rmd.rate_master_id= =3D'12'where r.route_id=3D'3004' AND bs.point_type_id NOT IN ('2', '13') o= rder by r.route_id; ________________________________ From: pgsql-admin-owner@postgresql.org [pgsql-admin-owner@postgresql.org] o= n behalf of Ankur Kaushik [ankurkaushik@gmail.com] Sent: Friday, June 26, 2015 4:13 AM To: pgsql-admin@postgresql.org Subject: [ADMIN] select query of mysql to postgres I Have below query of mysql which is not executing in postgresql , What cha= nges need to do to execute in postgressql database select bs.toll_zone, bs.toll_fee, concat(r.route_number,if(r.route_directio= n=3D'UP','UP','DN')) route_number, route_order, r.route_id, ifnull(bs.bus_s= top_code, bs.bus_stop_id) bus_stop_code, ifnull(bs.bus_stop_name, '') bus_s= top_name, (ifnull(bs.bus_stop_name_nudi, '')) bus_stop_name_nudi, bs.bus_st= op_id, ifnull(bs.alias1, '') alias1, IF( if(ifnull(rm.schedule_distance, 0)= =3D'0',ifnull(rm.distance, 0),ifnull(rm.schedule_distance, 0)) IS NULL, @to= t_dur :=3D @tot_dur, @tot_dur :=3D @tot_dur + if(ifnull(rm.schedule_distanc= e, 0)=3D'0',ifnull(rm.distance, 0),ifnull(rm.schedule_distance, 0)) )/1000 = AS tot_dist, ifnull(rp.sub_stage,'N') sub_stage, ifnull(rp.fare_stage,'N') = fare_stage,a.stage_count, rmd.adult, rmd.children, rmd.senior_citizenfrom r= oute r JOIN (SELECT @tot_dur :=3D 0) d inner join route_point rp on rp.rout= e_id =3D r.route_id inner join bus_stop bs on bs.bus_stop_id=3Drp.bus_stop_= id and bs.point_type_id!=3D2 left join route_map rm on rm.start_bus_stop_id= =3Drp.bus_stop_id and rp.route_id=3D'3004' and rm.route_id=3D'3004' INNER J= OIN (select route_id, route_points_id, if(if(rp.fare_stage=3D'Y',1,0) IS NU= LL,@stage_count :=3D @stage_count,@stage_count :=3D @stage_count+if(rp.fare= _stage=3D'Y',1,0)) as stage_count from route_point rp JOIN (SELECT @stage_c= ount :=3D 0) e where rp.route_id=3D'3004' ) aON rp.route_points_id =3D a.ro= ute_points_id INNER JOIN rate_master_details rmd ON a.stage_count =3D rmd.s= tage_no AND rmd.rate_master_id=3D'12'where r.route_id=3D'3004' AND bs.point= _type_id NOT IN ('2', '13') order by r.route_id; --_000_77F5F8FA4B407F43BFCFD3FC3478969108EC9201COVMSGCESMBX01_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Two things - 1) Off the top of my head I would guess that the "= @" symbols refer to something that is mysql specific (or in my limited= postgresql experience, I have not seen/used it), 2) you should include an error message, cause that will tell you what= type of error and approximate location, 3) to get help on this it may help= other people if you formatted your query in a way that was more legible. &= nbsp;For example:

selec= t bs.toll_zone, bs.toll_fee, 
 = ; concat(r.route_number,if(r.route_direction=3D'UP','UP','DN')) route_numbe= r, 
 = ; route_order, r.route_id, 
 = ; ifnull(bs.bus_stop_code, bs.bus_stop_id) bus_stop_code, 
 = ; ifnull(bs.bus_stop_name, '') bus_stop_name, 
 = ; (ifnull(bs.bus_stop_name_nudi, '')) bus_stop_name_nudi, 
 = ; bs.bus_stop_id, ifnull(bs.alias1, '') alias1, 
 = ; IF( if(ifnull(rm.schedule_distance, 0)=3D'0',ifnull(rm.distance, 0),ifnul= l(rm.schedule_distance, 0)) IS NULL, @tot_dur :=3D @tot_dur, @tot_dur :=3D = @tot_dur + if(ifnull(rm.schedule_distance, 0)=3D'0',ifnull(rm.distance, 0),ifnull(rm.schedule_distance, 0)) )/1000 AS tot_dist, ifnull(rp.sub_stag= e,'N') sub_stage, ifnull(rp.fare_stage,'N') fare_stage,a.stage_count, rmd.a= dult, rmd.children, rmd.senior_citizenfrom route r JOIN (SELECT @tot_dur := =3D 0) d inner join route_point rp on rp.route_id =3D r.route_id inner join bus_stop bs on bs.bus_stop_id=3Dr= p.bus_stop_id and bs.point_type_id!=3D2 left join route_map rm on rm.start_= bus_stop_id=3Drp.bus_stop_id and rp.route_id=3D'3004' and rm.route_id=3D'30= 04' INNER JOIN (select route_id, route_points_id, if(if(rp.fare_stage=3D'Y',1,0) IS NULL,@stage_count :=3D @stage_count,@sta= ge_count :=3D @stage_count+if(rp.fare_stage=3D'Y',1,0)) as stage_count = from route_point rp JOIN (SELECT @stage_count :=3D 0) e where rp.route_id= =3D'3004' ) aON rp.route_points_id =3D a.route_points_id INNER JOIN rate_master_details rmd ON a.stage_count =3D rmd.stage_no AND r= md.rate_master_id=3D'12'where r.route_id=3D'3004' AND bs.point_type_id NOT = IN ('2', '13')  order by r.route_id;

From: pgsql-admin-owner@postgresql.org [p= gsql-admin-owner@postgresql.org] on behalf of Ankur Kaushik [ankurkaushik@g= mail.com]
Sent: Friday, June 26, 2015 4:13 AM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] select query of mysql to postgres

I Have below query of mysql which is not executing in post= gresql , What changes need to do to execute in postgressql database

select bs.toll_zone, bs.toll_fee, concat(r.route_num= ber,if(r.route_direction=3D'UP','UP','DN')) route_number, route_order, r.ro= ute_id, ifnull(bs.bus_stop_code, bs.bus_stop_id) bus_stop_code, ifnull(bs.b= us_stop_name, '') bus_stop_name, (ifnull(bs.bus_stop_name_nudi, '')) bus_stop_name_nudi, bs.bus_stop_id, ifnull(bs.alias1, '') alias1, IF(= if(ifnull(rm.schedule_distance, 0)=3D'0',ifnull(rm.distance, 0),ifnull(rm.= schedule_distance, 0)) IS NULL, @tot_dur :=3D @tot_dur, @tot_dur :=3D @tot_= dur + if(ifnull(rm.schedule_distance, 0)=3D'0',ifnull(rm.distance, 0),ifnull(rm.schedule_distance, 0)) )/1000 AS= tot_dist, ifnull(rp.sub_stage,'N') sub_stage, ifnull(rp.fare_stage,'N') fa= re_stage,a.stage_count, rmd.adult, rmd.children, rmd.senior_citizenfrom rou= te r JOIN (SELECT @tot_dur :=3D 0) d inner join route_point rp on rp.route_id =3D r.route_id inner join bus_sto= p bs on bs.bus_stop_id=3Drp.bus_stop_id and bs.point_type_id!=3D2 left join= route_map rm on rm.start_bus_stop_id=3Drp.bus_stop_id and rp.route_id=3D'3= 004' and rm.route_id=3D'3004' INNER JOIN (select route_id, route_points_id, if(if(rp.fare_stage=3D'Y',1,0) IS NULL,@stage_c= ount :=3D @stage_count,@stage_count :=3D @stage_count+if(rp.fare_stage= =3D'Y',1,0)) as stage_count from route_point rp JOIN (SELECT @stage_count := =3D 0) e where rp.route_id=3D'3004' ) aON rp.route_points_id =3D a.route_points_id INNER JOIN rate_master_details rmd ON a.stage_count = =3D rmd.stage_no AND rmd.rate_master_id=3D'12'where r.route_id=3D'3004' AND= bs.point_type_id NOT IN ('2', '13')  order by r.route_id;

--_000_77F5F8FA4B407F43BFCFD3FC3478969108EC9201COVMSGCESMBX01_--