pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Burgholzer, Robert (DEQ) <Robert.Burgholzer@deq.virginia.gov>
To: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: select query of mysql to postgres
Date: Fri, 26 Jun 2015 11:03:01 +0000
Message-ID: <77F5F8FA4B407F43BFCFD3FC3478969108EC9201@COVMSGCES-MBX01> (raw)
In-Reply-To: <CALXoLqz0=1_hy6XpX3QriPgFLPtW8r8YC=yCQw3WSSr9Z0dQuw@mail.gmail.com>
References: <CALXoLqz0=1_hy6XpX3QriPgFLPtW8r8YC=yCQw3WSSr9Z0dQuw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>

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.  For example:

select bs.toll_zone, bs.toll_fee,
  concat(r.route_number,if(r.route_direction='UP','UP','DN')) route_number,
  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)='0',ifnull(rm.distance, 0),ifnull(rm.schedule_distance, 0)) IS NULL, @tot_dur := @tot_dur, @tot_dur := @tot_dur + if(ifnull(rm.schedule_distance, 0)='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 := 0) d inner join route_point rp on rp.route_id = r.route_id inner join bus_stop bs on bs.bus_stop_id=rp.bus_stop_id and bs.point_type_id!=2 left join route_map rm on rm.start_bus_stop_id=rp.bus_stop_id and rp.route_id='3004' and rm.route_id='3004' INNER JOIN (select route_id, route_points_id, if(if(rp.fare_stage='Y',1,0) IS NULL,@stage_count := @stage_count,@stage_count := @stage_count+if(rp.fare_stage='Y',1,0)) as stage_count from route_point rp JOIN (SELECT @stage_count := 0) e where rp.route_id='3004' ) aON rp.route_points_id = a.route_points_id INNER JOIN rate_master_details rmd ON a.stage_count = rmd.stage_no AND rmd.rate_master_id='12'where r.route_id='3004' AND bs.point_type_id NOT IN ('2', '13')  order by r.route_id;

________________________________
From: pgsql-admin-owner@postgresql.org [pgsql-admin-owner@postgresql.org] on 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 changes need to do to execute in postgressql database

select bs.toll_zone, bs.toll_fee, concat(r.route_number,if(r.route_direction='UP','UP','DN')) route_number, 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)='0',ifnull(rm.distance, 0),ifnull(rm.schedule_distance, 0)) IS NULL, @tot_dur := @tot_dur, @tot_dur := @tot_dur + if(ifnull(rm.schedule_distance, 0)='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 := 0) d inner join route_point rp on rp.route_id = r.route_id inner join bus_stop bs on bs.bus_stop_id=rp.bus_stop_id and bs.point_type_id!=2 left join route_map rm on rm.start_bus_stop_id=rp.bus_stop_id and rp.route_id='3004' and rm.route_id='3004' INNER JOIN (select route_id, route_points_id, if(if(rp.fare_stage='Y',1,0) IS NULL,@stage_count := @stage_count,@stage_count := @stage_count+if(rp.fare_stage='Y',1,0)) as stage_count from route_point rp JOIN (SELECT @stage_count := 0) e where rp.route_id='3004' ) aON rp.route_points_id = a.route_points_id INNER JOIN rate_master_details rmd ON a.stage_count = rmd.stage_no AND rmd.rate_master_id='12'where r.route_id='3004' AND bs.point_type_id NOT IN ('2', '13')  order by r.route_id;

view thread (9+ messages)  latest in thread

Message-ID: <77F5F8FA4B407F43BFCFD3FC3478969108EC9201@COVMSGCES-MBX01>
Permalink:  ../77F5F8FA4B407F43BFCFD3FC3478969108EC9201@COVMSGCES-MBX01/
Also on:    postgresql.org/message-id/77F5F8FA4B407F43BFCFD3FC3478969108EC9201@COVMSGCES-MBX01

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: Robert.Burgholzer@deq.virginia.gov
  Subject: Re: select query of mysql to postgres
  In-Reply-To: <77F5F8FA4B407F43BFCFD3FC3478969108EC9201@COVMSGCES-MBX01>
  References: <CALXoLqz0=1_hy6XpX3QriPgFLPtW8r8YC=yCQw3WSSr9Z0dQuw@mail.gmail.com> <77F5F8FA4B407F43BFCFD3FC3478969108EC9201@COVMSGCES-MBX01>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox