473,785 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

query in conflict with a table

In my query, consisting of 2 tables, customers and orders,i get the
employeeid number ordered with a given customer.
The query is the following :

SELECT orders.orderid, Customers.Custo merid, Customers.Emplo yeeID
FROM orders INNER JOIN Customers ON orders.customer id =
Customers.Custo merid;

If i add on another table in the query, the tables Employees, then my
query
doesnt show anything.If i remove the table employes from the query,
then the query is
ok again.Obviously the table employees is not convenient for the
query. I need the table

Employees in order to from there the LastName of the
employee.The tables customers and employees are related one to many,
one employee may have many

customers.
How do you solve such problems with queries ?
Nov 12 '05 #1
1 1566
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Perhaps:

SELECT o.orderid, c.Customerid, o.EmployeeID, e.LastName
FROM (orders as o INNER JOIN Customers as c
ON o.Customerid = c.Customerid) INNER JOIN Employees As e
ON o.EmployeeID = e.EmployeeID

Table design:

You should have the EmployeeID in the Orders table not in the
Customers table: an order has an employee (who handled the creation
of the order) and a customer (who requested the item). Customers
don't HAVE employees (unless you got something kinky going on). In
the Orders table the EmployeeID should be required, as should the
CustomerID - then you can't have an order w/o the person who requested
it & the person who handled it.
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQEJMC4echKq OuFEgEQLGJwCfW7 J94dOI2G2o4ScG7 atcIcbJoskAnRVM
GNqK13ghXBRhSd2 F3NF+UEnb
=/H0r
-----END PGP SIGNATURE-----
Johm wrote:
In my query, consisting of 2 tables, customers and orders,i get the
employeeid number ordered with a given customer.
The query is the following :

SELECT orders.orderid, Customers.Custo merid, Customers.Emplo yeeID
FROM orders INNER JOIN Customers ON orders.customer id =
Customers.Custo merid;

If i add on another table in the query, the tables Employees, then my
query
doesnt show anything.If i remove the table employes from the query,
then the query is
ok again.Obviously the table employees is not convenient for the
query. I need the table

Employees in order to from there the LastName of the
employee.The tables customers and employees are related one to many,
one employee may have many

customers.
How do you solve such problems with queries ?


Nov 12 '05 #2

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

Similar topics

6
2254
by: postings | last post by:
Hi I'm trying to port some data from one database table to another database table on the same server. This is the query I am using: -----> INSERT into newdatabase.dbo.contactevents (EventTypeID, UserID, ContactID, DateEntered, EventDate, Description)
2
1845
by: LoopyNZ | last post by:
Hi, (Access 97) I'm creating a query (QRY_SUMMARY) to join a query (QRY) to itself (QRY_1). I'm returning QRY.* and selected fields from QRY_1. With each field (field_name) I return from QRY_1 I'm appending "_1" to to the end to avoid name conflicts with the fields from QRY, i.e. "field_name" becomes "field_name_1".
10
2111
by: Robert | last post by:
I am an attorney in a non-profit organization and a self-taught programmer. I'm trying to create a client db that will allow me to search for potential conflicts of interest based either on Social Security # or on Last Name. I've created two different tables with the following fields in each table: ClientInfo Client# (primary key) First Name Middle Name Last Name
4
8507
by: crystal | last post by:
I've checked the threads but haven't been able to come up with a solution to my issue. Help...... I have a simple form based on a table. Within the form is a subform that is also, through a Q, based on the same table. The code: Private Sub Select_BeforeUpdate(Cancel As Integer) On Error GoTo resetselect_Err
5
14773
by: laurentc | last post by:
Dear all, I have several tables based on exactly the same fields (Key/Date/Price1/Price2). I do some statistics on the prices. However, as I have many different tables (the tables are different because I directly import the data from a .csv file), I do not want to create dozens of queries to be able to get the results of the different tables.
1
2449
by: lorirobn | last post by:
Hi, I have a query that I have been using as a record source for a form with no problems. I just created a new "addnew" form, and added 20 records to the table with this form. The problem I now have is I cannot modify data on these new records using my query. The query's sql is: SELECT tblSpaceUse.* FROM tblSpaceUse; The error I get is: "Write Conflict -
2
2745
by: joeybarbecho | last post by:
hello... I have a program that saves dates. Problem: Given: sample table: Leave ------------------------------------------ ID | UserID | DateFrom | DateTo| ----------------------------------------------------
14
6905
lotus18
by: lotus18 | last post by:
Hello all I have these records on my Day Table for my complete database table please click here 1. M 2. T 3. W 4. TH 5. F 6. S
7
2797
by: quincy451 | last post by:
drop table . CREATE TABLE . ( NULL , (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , NULL , NULL , (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , (16) COLLATE
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10356
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10098
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9958
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7506
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.