473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Emulating subqueries with temp tables in MySQL 3.23.55

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
Jul 19 '05 #1
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
Jul 19 '05 #2
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
Jul 19 '05 #3
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
Jul 19 '05 #4
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
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
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...
0
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...
6
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...
3
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...
5
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...
3
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...
2
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? ...
6
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: ...
5
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
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...
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.