help with this query

This is a discussion on help with this query within the MySQL Database forums, part of the Database Forums category; I am completely clueless about the following query. - - Where does the longest flight go? This relates to 2 tables and ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-14-2007
ros
 
Posts: n/a
Default help with this query

I am completely clueless about the following query.

- - Where does the longest flight go?

This relates to 2 tables and the sql scripts are as follows:

CREATE TABLE `my-database`.`flight_profiles` (
`FLP_ID` decimal(8,0) default NULL,
`FLT_NUMB` decimal(4,0) default NULL,
`PRICE_CODE` varchar(50) default NULL,
`FLT_FROM` varchar(50) default NULL,
`FLT_TO` varchar(50) default NULL,
`depart` datetime default NULL,
`arrive` datetime default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


CREATE TABLE `my-database`.`cities` (
`IATA_CODE` varchar(3) default NULL,
`COU_IATA_CODE` varchar(2) default NULL,
`NAME` varchar(40) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Would appreciate help with this one. Also I am just building my SQL
and MySQL skills so any recommendations on resources like books or
online resources would be most welcome.

Thanks

ros

Reply With Quote
  #2 (permalink)  
Old 04-14-2007
Paul Lautman
 
Posts: n/a
Default Re: help with this query

ros wrote:
> I am completely clueless about the following query.
>
> - - Where does the longest flight go?

That depends on where it is leaving from. From where I am I think it is
Australia.

>
> This relates to 2 tables and the sql scripts are as follows:
>
> CREATE TABLE `my-database`.`flight_profiles` (
> `FLP_ID` decimal(8,0) default NULL,
> `FLT_NUMB` decimal(4,0) default NULL,
> `PRICE_CODE` varchar(50) default NULL,
> `FLT_FROM` varchar(50) default NULL,
> `FLT_TO` varchar(50) default NULL,
> `depart` datetime default NULL,
> `arrive` datetime default NULL
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
>
>
> CREATE TABLE `my-database`.`cities` (
> `IATA_CODE` varchar(3) default NULL,
> `COU_IATA_CODE` varchar(2) default NULL,
> `NAME` varchar(40) default NULL
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
>
> Would appreciate help with this one. Also I am just building my SQL
> and MySQL skills so any recommendations on resources like books or
> online resources would be most welcome.
>
> Thanks
>
> ros

The tables are very interesting, but what do you want us to help with?



Reply With Quote
  #3 (permalink)  
Old 04-14-2007
strawberry
 
Posts: n/a
Default Re: help with this query

On Apr 14, 10:05 pm, "Paul Lautman" <paul.laut...@btinternet.com>
wrote:
> ros wrote:
> > I am completely clueless about the following query.

>
> > - - Where does the longest flight go?

>
> That depends on where it is leaving from. From where I am I think it is
> Australia.
>
>
>
>
>
> > This relates to 2 tables and the sql scripts are as follows:

>
> > CREATE TABLE `my-database`.`flight_profiles` (
> > `FLP_ID` decimal(8,0) default NULL,
> > `FLT_NUMB` decimal(4,0) default NULL,
> > `PRICE_CODE` varchar(50) default NULL,
> > `FLT_FROM` varchar(50) default NULL,
> > `FLT_TO` varchar(50) default NULL,
> > `depart` datetime default NULL,
> > `arrive` datetime default NULL
> > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > CREATE TABLE `my-database`.`cities` (
> > `IATA_CODE` varchar(3) default NULL,
> > `COU_IATA_CODE` varchar(2) default NULL,
> > `NAME` varchar(40) default NULL
> > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > Would appreciate help with this one. Also I am just building my SQL
> > and MySQL skills so any recommendations on resources like books or
> > online resources would be most welcome.

>
> > Thanks

>
> > ros

>
> The tables are very interesting, but what do you want us to help with?



:-)

isn't this a clue?

`depart` datetime default NULL,
`arrive` datetime default NULL

Reply With Quote
  #4 (permalink)  
Old 04-15-2007
ros
 
Posts: n/a
Default Re: help with this query

On Apr 14, 3:58 pm, "strawberry" <zac.ca...@gmail.com> wrote:
> On Apr 14, 10:05 pm, "Paul Lautman" <paul.laut...@btinternet.com>
> wrote:
>
>
>
> > ros wrote:
> > > I am completely clueless about the following query.

>
> > > - - Where does the longest flight go?

>
> > That depends on where it is leaving from. From where I am I think it is
> > Australia.

>
> > > This relates to 2 tables and the sql scripts are as follows:

>
> > > CREATE TABLE `my-database`.`flight_profiles` (
> > > `FLP_ID` decimal(8,0) default NULL,
> > > `FLT_NUMB` decimal(4,0) default NULL,
> > > `PRICE_CODE` varchar(50) default NULL,
> > > `FLT_FROM` varchar(50) default NULL,
> > > `FLT_TO` varchar(50) default NULL,
> > > `depart` datetime default NULL,
> > > `arrive` datetime default NULL
> > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > > CREATE TABLE `my-database`.`cities` (
> > > `IATA_CODE` varchar(3) default NULL,
> > > `COU_IATA_CODE` varchar(2) default NULL,
> > > `NAME` varchar(40) default NULL
> > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > > Would appreciate help with this one. Also I am just building my SQL
> > > and MySQL skills so any recommendations on resources like books or
> > > online resources would be most welcome.

>
> > > Thanks

>
> > > ros

>
> > The tables are very interesting, but what do you want us to help with?

>
> :-)
>
> isn't this a clue?
>
> `depart` datetime default NULL,
> `arrive` datetime default NULL


That was hilarious!
Actually I need help in writing this query which gives me the name of
the city where the longest flight go from these 2 tables.
Would be thankful for guidance.
ros

Reply With Quote
  #5 (permalink)  
Old 04-15-2007
strawberry
 
Posts: n/a
Default Re: help with this query

On Apr 15, 9:15 am, "ros" <ros...@gmail.com> wrote:
> On Apr 14, 3:58 pm, "strawberry" <zac.ca...@gmail.com> wrote:
>
>
>
> > On Apr 14, 10:05 pm, "Paul Lautman" <paul.laut...@btinternet.com>
> > wrote:

>
> > > ros wrote:
> > > > I am completely clueless about the following query.

>
> > > > - - Where does the longest flight go?

>
> > > That depends on where it is leaving from. From where I am I think it is
> > > Australia.

>
> > > > This relates to 2 tables and the sql scripts are as follows:

>
> > > > CREATE TABLE `my-database`.`flight_profiles` (
> > > > `FLP_ID` decimal(8,0) default NULL,
> > > > `FLT_NUMB` decimal(4,0) default NULL,
> > > > `PRICE_CODE` varchar(50) default NULL,
> > > > `FLT_FROM` varchar(50) default NULL,
> > > > `FLT_TO` varchar(50) default NULL,
> > > > `depart` datetime default NULL,
> > > > `arrive` datetime default NULL
> > > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > > > CREATE TABLE `my-database`.`cities` (
> > > > `IATA_CODE` varchar(3) default NULL,
> > > > `COU_IATA_CODE` varchar(2) default NULL,
> > > > `NAME` varchar(40) default NULL
> > > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > > > Would appreciate help with this one. Also I am just building my SQL
> > > > and MySQL skills so any recommendations on resources like books or
> > > > online resources would be most welcome.

>
> > > > Thanks

>
> > > > ros

>
> > > The tables are very interesting, but what do you want us to help with?

>
> > :-)

>
> > isn't this a clue?

>
> > `depart` datetime default NULL,
> > `arrive` datetime default NULL

>
> That was hilarious!
> Actually I need help in writing this query which gives me the name of
> the city where the longest flight go from these 2 tables.
> Would be thankful for guidance.
> ros


Note that you may need to take account of timezones. Also I don't
understand the relationship between the cities table and the
flight_profiles table, so I've ignored the cities table for the
purposes of this query:

SELECT FLP_ID, FLT_FROM, FLT_TO, TIMESTAMPDIFF(
SECOND , depart, arrive ) duration
FROM flight_profiles
ORDER BY duration DESC;

Reply With Quote
  #6 (permalink)  
Old 04-16-2007
ros
 
Posts: n/a
Default Re: help with this query

On Apr 15, 3:02 am, "strawberry" <zac.ca...@gmail.com> wrote:
> On Apr 15, 9:15 am, "ros" <ros...@gmail.com> wrote:
>
>
>
> > On Apr 14, 3:58 pm, "strawberry" <zac.ca...@gmail.com> wrote:

>
> > > On Apr 14, 10:05 pm, "Paul Lautman" <paul.laut...@btinternet.com>
> > > wrote:

>
> > > > ros wrote:
> > > > > I am completely clueless about the following query.

>
> > > > > - - Where does the longest flight go?

>
> > > > That depends on where it is leaving from. From where I am I think it is
> > > > Australia.

>
> > > > > This relates to 2 tables and the sql scripts are as follows:

>
> > > > > CREATE TABLE `my-database`.`flight_profiles` (
> > > > > `FLP_ID` decimal(8,0) default NULL,
> > > > > `FLT_NUMB` decimal(4,0) default NULL,
> > > > > `PRICE_CODE` varchar(50) default NULL,
> > > > > `FLT_FROM` varchar(50) default NULL,
> > > > > `FLT_TO` varchar(50) default NULL,
> > > > > `depart` datetime default NULL,
> > > > > `arrive` datetime default NULL
> > > > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > > > > CREATE TABLE `my-database`.`cities` (
> > > > > `IATA_CODE` varchar(3) default NULL,
> > > > > `COU_IATA_CODE` varchar(2) default NULL,
> > > > > `NAME` varchar(40) default NULL
> > > > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > > > > Would appreciate help with this one. Also I am just building my SQL
> > > > > and MySQL skills so any recommendations on resources like books or
> > > > > online resources would be most welcome.

>
> > > > > Thanks

>
> > > > > ros

>
> > > > The tables are very interesting, but what do you want us to help with?

>
> > > :-)

>
> > > isn't this a clue?

>
> > > `depart` datetime default NULL,
> > > `arrive` datetime default NULL

>
> > That was hilarious!
> > Actually I need help in writing this query which gives me the name of
> > the city where the longest flight go from these 2 tables.
> > Would be thankful for guidance.
> > ros

>
> Note that you may need to take account of timezones. Also I don't
> understand the relationship between the cities table and the
> flight_profiles table, so I've ignored the cities table for the
> purposes of this query:
>
> SELECT FLP_ID, FLT_FROM, FLT_TO, TIMESTAMPDIFF(
> SECOND , depart, arrive ) duration
> FROM flight_profiles
> ORDER BY duration DESC;


Thanks a lot Strawberry. That was extremely helpful.
I really appreciate that.
ros

Reply With Quote
  #7 (permalink)  
Old 04-16-2007
Captain Paralytic
 
Posts: n/a
Default Re: help with this query

On 14 Apr, 23:58, "strawberry" <zac.ca...@gmail.com> wrote:
> On Apr 14, 10:05 pm, "Paul Lautman" <paul.laut...@btinternet.com>
> wrote:
>
>
>
>
>
> > ros wrote:
> > > I am completely clueless about the following query.

>
> > > - - Where does the longest flight go?

>
> > That depends on where it is leaving from. From where I am I think it is
> > Australia.

>
> > > This relates to 2 tables and the sql scripts are as follows:

>
> > > CREATE TABLE `my-database`.`flight_profiles` (
> > > `FLP_ID` decimal(8,0) default NULL,
> > > `FLT_NUMB` decimal(4,0) default NULL,
> > > `PRICE_CODE` varchar(50) default NULL,
> > > `FLT_FROM` varchar(50) default NULL,
> > > `FLT_TO` varchar(50) default NULL,
> > > `depart` datetime default NULL,
> > > `arrive` datetime default NULL
> > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > > CREATE TABLE `my-database`.`cities` (
> > > `IATA_CODE` varchar(3) default NULL,
> > > `COU_IATA_CODE` varchar(2) default NULL,
> > > `NAME` varchar(40) default NULL
> > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > > Would appreciate help with this one. Also I am just building my SQL
> > > and MySQL skills so any recommendations on resources like books or
> > > online resources would be most welcome.

>
> > > Thanks

>
> > > ros

>
> > The tables are very interesting, but what do you want us to help with?

>
> :-)
>
> isn't this a clue?
>
> `depart` datetime default NULL,
> `arrive` datetime default NULL- Hide quoted text -
>
> - Show quoted text -


I was thinking of "longest" as in distance!

Reply With Quote
  #8 (permalink)  
Old 04-16-2007
strawberry
 
Posts: n/a
Default Re: help with this query

On Apr 16, 10:34 am, "Captain Paralytic" <paul_laut...@yahoo.com>
wrote:
> On 14 Apr, 23:58, "strawberry" <zac.ca...@gmail.com> wrote:
>
>
>
> > On Apr 14, 10:05 pm, "Paul Lautman" <paul.laut...@btinternet.com>
> > wrote:

>
> > > ros wrote:
> > > > I am completely clueless about the following query.

>
> > > > - - Where does the longest flight go?

>
> > > That depends on where it is leaving from. From where I am I think it is
> > > Australia.

>
> > > > This relates to 2 tables and the sql scripts are as follows:

>
> > > > CREATE TABLE `my-database`.`flight_profiles` (
> > > > `FLP_ID` decimal(8,0) default NULL,
> > > > `FLT_NUMB` decimal(4,0) default NULL,
> > > > `PRICE_CODE` varchar(50) default NULL,
> > > > `FLT_FROM` varchar(50) default NULL,
> > > > `FLT_TO` varchar(50) default NULL,
> > > > `depart` datetime default NULL,
> > > > `arrive` datetime default NULL
> > > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > > > CREATE TABLE `my-database`.`cities` (
> > > > `IATA_CODE` varchar(3) default NULL,
> > > > `COU_IATA_CODE` varchar(2) default NULL,
> > > > `NAME` varchar(40) default NULL
> > > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > > > Would appreciate help with this one. Also I am just building my SQL
> > > > and MySQL skills so any recommendations on resources like books or
> > > > online resources would be most welcome.

>
> > > > Thanks

>
> > > > ros

>
> > > The tables are very interesting, but what do you want us to help with?

>
> > :-)

>
> > isn't this a clue?

>
> > `depart` datetime default NULL,
> > `arrive` datetime default NULL- Hide quoted text -

>
> > - Show quoted text -

>
> I was thinking of "longest" as in distance!


I know

Reply With Quote
  #9 (permalink)  
Old 04-16-2007
ros
 
Posts: n/a
Default Re: help with this query

On Apr 16, 2:54 am, "strawberry" <zac.ca...@gmail.com> wrote:
> On Apr 16, 10:34 am, "Captain Paralytic" <paul_laut...@yahoo.com>
> wrote:
>
>
>
> > On 14 Apr, 23:58, "strawberry" <zac.ca...@gmail.com> wrote:

>
> > > On Apr 14, 10:05 pm, "Paul Lautman" <paul.laut...@btinternet.com>
> > > wrote:

>
> > > > ros wrote:
> > > > > I am completely clueless about the following query.

>
> > > > > - - Where does the longest flight go?

>
> > > > That depends on where it is leaving from. From where I am I think it is
> > > > Australia.

>
> > > > > This relates to 2 tables and the sql scripts are as follows:

>
> > > > > CREATE TABLE `my-database`.`flight_profiles` (
> > > > > `FLP_ID` decimal(8,0) default NULL,
> > > > > `FLT_NUMB` decimal(4,0) default NULL,
> > > > > `PRICE_CODE` varchar(50) default NULL,
> > > > > `FLT_FROM` varchar(50) default NULL,
> > > > > `FLT_TO` varchar(50) default NULL,
> > > > > `depart` datetime default NULL,
> > > > > `arrive` datetime default NULL
> > > > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > > > > CREATE TABLE `my-database`.`cities` (
> > > > > `IATA_CODE` varchar(3) default NULL,
> > > > > `COU_IATA_CODE` varchar(2) default NULL,
> > > > > `NAME` varchar(40) default NULL
> > > > > ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

>
> > > > > Would appreciate help with this one. Also I am just building my SQL
> > > > > and MySQL skills so any recommendations on resources like books or
> > > > > online resources would be most welcome.

>
> > > > > Thanks

>
> > > > > ros

>
> > > > The tables are very interesting, but what do you want us to help with?

>
> > > :-)

>
> > > isn't this a clue?

>
> > > `depart` datetime default NULL,
> > > `arrive` datetime default NULL- Hide quoted text -

>
> > > - Show quoted text -

>
> > I was thinking of "longest" as in distance!

>
> I know


Sorry about the confusion but actually it was the duration!

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:56 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0