Help with basestation.sqb

Want to post something that doesn't quite fit into the other forums? This is the place for that.
Post Reply
jdor
Posts: 51
Joined: Sun Aug 26, 2018 1:41 pm

Help with basestation.sqb

Post by jdor » Mon Sep 17, 2018 8:05 pm

What data populates the "Aircraft" table and the "Flight" table ? should they not both contain the same amount of records ?

eg Aircraft table contains 60k records while the Flights table only contains 2k

second question can anybody help with merging the 2 tables Aircraft and Flights. I simply want to (re)create the Aircraft table but with the indices callsign from the flights table.

after doing some reading on sql

I ran
select * from Aircraft
(which correctly showed all records within that table then after a little more reading I ran the sql query below
select * from Aircraft inner join Flights on Aircraft.AircraftID = Flights.AircraftID order by FlightID

which did include the callsign

is this the best/ most efficient way of doing this ?

agw
Posts: 2146
Joined: Fri Feb 17, 2012 3:20 am

Re: Help with basestation.sqb

Post by agw » Tue Sep 18, 2018 12:42 am

Aircraft is the aircraft details, Flight is all the times the aircraft has been seen. You would normally expect Flight to outnumber Aircraft unless the BaseStation.sqb was originally a pre-populated SQB. They usually come with a lot of aircraft and no flights so those 2K flights will be the ones you've seen since you acquired the SQB.

That join will do the trick and it is the most efficient way of joining the two tables if you really want everything from both tables. If you're only interested in a particular aircraft then adding a where clause will be quicker, e.g. select * from Aircraft join Flights on Aircraft.AircraftID = Flights.AircraftID where Aircraft.ModeS = '414243' order by Aircraft.AircraftID, Flights.FlightsID

I can't quite remember the field names but you get the gist. The where clause goes between the from/joins and the order by (if you have one). SQL strings are delimited by apostrophes, not double-quotes.

jdor
Posts: 51
Joined: Sun Aug 26, 2018 1:41 pm

Re: Help with basestation.sqb

Post by jdor » Tue Sep 18, 2018 9:34 pm

Thank you, this is just what I was looking for

Post Reply