Hi everybody! I hope you can gimme a hand with this:
I just found out that the server I'm writing some code
for only has MySQL 3.23.55 which unfortunately doesn't
support subqueries (and dumb me I spent so much time
trying to make them work thinking it was a syntax problem).
So, I gotta find another way around.
I think temporary tables are the way to go, but I
can't find enough examples to put beside the manual
to full understand them. Any pointer to some resources
about this?
Specifically what I have are two tables:
- The first holds information about the flights in a timetable:
flight number, departure airport and arrival airport. Each
row is unique here.
- The second is basically a list of flights actually flown,
each flight identified by the flight number but not necessarily
unique or even present as a flight could have been flown
0, 1 or N times.
What I'd like is a query resulting in: flight number,
departure airport, arrival airport and "number of
time the flight has been flown".
The following query appearently worked:
SELECT t.flight, t.dpt, t.arr, count(*) as nb
FROM timetable t, flownlist f
WHERE t.flight=f.flightnumber
GROUP BY f.flight
ORDER BY nb
Unfortunately, I realized that flights never flown
but present in the timetable were not available in
the query's result as they are not present in the
flownlist.
How could I deal with this?
Thanks in advance.
Manu 4 2044
Excuse me folks,
is my question:
A) impossible to answer
B) impossible to understand
C) already answered somewherelse
D) too boring to deserve an answer
E) Other...
Manu
Excuse me folks,
is my question:
A) impossible to answer
B) impossible to understand
C) already answered somewherelse
D) too boring to deserve an answer
E) Other...
Manu
a little help..
Look at part8 of http://www.keithjbrown.co.uk/ for temporary tables.
i think you should use left outer join instead of where in your query. SELECT t.flight, t.dpt, t.arr, count(*) as nb FROM timetable t, flownlist f WHERE t.flight=f.flightnumber GROUP BY f.flight ORDER BY nb
try sth like
SELECT t.flight, t.dpt, t.arr, count(*) as nb
FROM timetable t
Left outer join flownlist f
on t.flight = f.flightnumber
group by f.flight
order by nb
a little help..
Look at part8 of http://www.keithjbrown.co.uk/ for temporary tables.
i think you should use left outer join instead of where in your query. SELECT t.flight, t.dpt, t.arr, count(*) as nb FROM timetable t, flownlist f WHERE t.flight=f.flightnumber GROUP BY f.flight ORDER BY nb
try sth like
SELECT t.flight, t.dpt, t.arr, count(*) as nb
FROM timetable t
Left outer join flownlist f
on t.flight = f.flightnumber
group by f.flight
order by nb This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: dev |
last post by:
how create a temp table as a copy of a existing table and then update1 field
and insert the hole temp table back in the existing table?
please any help?
if i have 10 fields in 1 record and...
|
by: Patrick Crowley |
last post by:
I'm creating a tool to browse a database of movie listings. The browser
pulls up 25 results at a time, and you can page through them using 'Next'
and 'Prev' tools. Pretty basic stuff.
Here are...
|
by: Daniel Elliott |
last post by:
Hello,
I was wondering if anyone would be able to help me with a problem I'm
having. I'm trying to use the following query:
SELECT Distinct c.site_id
FROM campsite c
WHERE c.site_id NOT IN...
|
by: compu_global_hyper_mega_net_2 |
last post by:
I'd like to do something like:
delete from a where id in (select * from b where pattern like
'%something%')
I may or may not have the syntax right. I know that this sort of
subquery isn't...
|
by: Nick |
last post by:
Im moving a development app (MySQL 5.0) to a different server which
runs MySQL 4.0.20-standard. I am getting errors on queries that have
subqueries such as...
SELECT id
FROM table1
WHERE id IN...
|
by: Noozer |
last post by:
Trying to get the following SQL to execute in MySQL 4.0...
SELECT DISTINCT CategoryID, tblCategory.Category FROM tblCategory AS A
INNER JOIN
(SELECT Cat FROM ( SELECT tblCategory.Category AS Cat...
|
by: Kevin |
last post by:
While converting SQL statements for a database change, I discovered a
big performance hit in MYSQL with subqueries vices Sybase. I'm hoping
that someone might be able to help me understand why?
...
|
by: J Belly |
last post by:
Hi, all:
This is probably a simple problem, but, as an SQL newbie, I'm having a
little trouble understanding multi-joins and subqueries.
I have the following tables and columns:
...
|
by: Jay |
last post by:
Hey there,
I have a question. Is it possible to to construct something through
a combination of php and javascript that (when a browser window is
closed) would drop temp tables that are used? I've...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |