473,320 Members | 1,926 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,320 software developers and data experts.

Query Across Multiple Tables

3
I'm having trouble figuring out how to run a query. I have a multitable database describing boating accidents. One table includes injured occupants, another table included deceased occupants. Other tables describe vessel and accident characteristics
. The deceased and injured tables are unrelated. Both tables have fields for propeller injury. I would like to run a query that combines all injured folks with prop injuries with all dead folks with prop injuries and allows me to look at things like vessel length, etc. If I only want to do deceased or injured I have no trouble, I can't seem to do a query that would basically allow me to find all lengths(from vessel table) for injured folks with prop injury(inj table) and also dead folks with prop injures(dec table)

I suspect there's and easy fix, but I'm not getting it...
Jun 30 '07 #1
3 1807
puppydogbuddy
1,923 Expert 1GB
I'm having trouble figuring out how to run a query. I have a multitable database describing boating accidents. One table includes injured occupants, another table included deceased occupants. Other tables describe vessel and accident characteristics
. The deceased and injured tables are unrelated. Both tables have fields for propeller injury. I would like to run a query that combines all injured folks with prop injuries with all dead folks with prop injuries and allows me to look at things like vessel length, etc. If I only want to do deceased or injured I have no trouble, I can't seem to do a query that would basically allow me to find all lengths(from vessel table) for injured folks with prop injury(inj table) and also dead folks with prop injures(dec table)

I suspect there's and easy fix, but I'm not getting it...
Your description was not clear as to exactly what fields are in the tables, so the query below assumes you have fields that identify the date of the accident Injury in all 3 tables,.and other fields as shown. You need to replace the field and table names with the actual field and table names in your database.

Expand|Select|Wrap|Line Numbers
  1. SELECT * From Vessel, Injury, Deceased
  2. WHERE  Vessel.AccidentDate = Injury.AccidentDate
  3. And Vessel.AccidentDate = Deceased.AccidentDate
  4. And Injury.Injury = "Propellar" And Deceased.Injury = "Propellar"
  5. Order By Vessel.Length, Vessel.AccidentDate
Jul 2 '07 #2
NeoPa
32,556 Expert Mod 16PB
I would say you need to normalise your database (Database Normalisation and Table structures).
Sure, it's possible to program around such poor design, but you're just making life harder for yourself. Similar items should be grouped together in a generic table with flags, where necessary, to differentiate the types.
Jul 2 '07 #3
NeoPa
32,556 Expert Mod 16PB
PS. I've changed the title in line with our Posting guidelines (Please Use Appropriate Titles for New Threads!). This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

MODERATOR.
Jul 2 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Jay | last post by:
Hi everyone ! I hope someone will be able to help me with this problem. I currently have several tables in MySQL database. Below is my table structures. (Data type for each fields are...
4
by: Bob Hotschins | last post by:
I've joined several columns from several tables, and I would like to perform a relevance match against these multiple columns. It looks something like this: SELECT * FROM table1 LEFT JOIN...
8
by: Rigga | last post by:
Hi, I am new to mysql and need help on how to join tables. I have a database which contains 4 tables, the main table contains information by date order and the other 3 contain data also in date...
1
by: RichardF | last post by:
Is it possible to run a single query that pulls data from multiple tables in multiple databases, perhaps also from multiple SQL Servers? Any input would be appreciated. Thanks! RichardF
1
by: John | last post by:
Hello, We are developing an application against an MS SQL Server 2000 database which requires that we implement full-text searching across columns in multiple tables. The research that we have...
1
by: fong.yang | last post by:
I've got a database with about 300,000 records. There are several different tables that are set up the same way with identical fields. I have the same queries individually set up for each table. ...
5
by: shaggydoink | last post by:
I've interacted with SQL DBs for years in project/product management roles, although admittedly still a newbie when it comes to actually building and manipulating things within SQL directly. I've...
5
by: MARIEDB2 | last post by:
Hello, I am struggling to build a query on a DB2 db wich does an update for multiple fields which are the result of a select query with where clause (using multiple tables in the condition). ...
1
by: cbrashear | last post by:
I am new to sql and have not been able to resolve this issue. I have a query that shows me the information on students we serve. The query pulls all of their classes and the status results as well as...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.