473,405 Members | 2,282 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,405 software developers and data experts.

Pull data from Two tables

I am new to SQL, as old as it is. I am not new to programming I
normally just use Access.

I have two tables for a little project manager I made. After updates I
sent an email to the user. I need to populate the user based on the
"Assigned To" field I use, but I only log the username and not the
email address. Is there a way to associate the "Assigned To" to the
User's account in the "User" table so that I can pull thier email
address through code?

Thanks
Chuck

Aug 22 '05 #1
5 2485
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. Sample data is also a good idea, along with clear
specifications. It is very hard to debug code when you do not let us
see it.

Aug 22 '05 #2
Thank you for the feedback, obviously your a genius, but I do not know
what to post since I already stated I am new to this. My question was
of a theory nature, as I do not know what DRI and contraints are.

I will try to simply my question even more...

1. I have a database with two tables Case and Users
2. When I finish updating a case I want to send an email to the
currently assigned users.
3. The email address is not stated in the Case table, so I would like
to know if there is a way when I guery the database I can also pull
data from another Table.

Aug 22 '05 #3
Stu
Hey Chuck,

What you're talking about is the guts of SQL: the JOIN. A newsgroup is
really not the best place to learn how to write SQL (from the ground
up), because it's gonna take some practice (and some background
knowledge) before you're really ready to even ask a question. There's
a couple of really good books on basic SQL out there; I'd recommend Be
Forta's Sams Teach Yourself SQL in 10 Minutes as a good primer on the
language.

Anyway, I think you might be looking at something like the following:

SELECT * --* is bad in production
FROM [CASE] c JOIN [Users] u ON c.[Assigned to] ON u.[UserName]

--note that case is a reserved word in SQL. Also, column names without
spaces are easier to manage.

Anyway, good luck on your quest.

Stu

Aug 22 '05 #4

"cvillard" <cv******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Thank you for the feedback, obviously your a genius, but I do not know
what to post since I already stated I am new to this. My question was
of a theory nature, as I do not know what DRI and contraints are.

DRI=Data Referential Integrity.

The important part is DDL - Data Definition Language.

What we need is the script to create your tables.

Something lie

CREATE TABLE cases (
case varchar(30),
case_id int
)

CREATE TABLE email (
case_id int,
case_email varchar(30)
)

DRI would include keys to make sure you can't have a case_id in email table
that doesn't exist in table cases, that case_email has a valid form, etc.

So, now

sounds like you want something like

select e.case_email from email as e inner join cases as c on
e.case_id=c.cases_id where e.case_id = 5
I will try to simply my question even more...

1. I have a database with two tables Case and Users
2. When I finish updating a case I want to send an email to the
currently assigned users.
3. The email address is not stated in the Case table, so I would like
to know if there is a way when I guery the database I can also pull
data from another Table.

Aug 22 '05 #5
Ok, thought what I was thinking was more simple, but I understand that
its more of a loaded question.

Thanks for the feedback and suggestions, I will start reading up.

Chuck

Aug 22 '05 #6

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

Similar topics

0
by: Allan Lockridge | last post by:
I need to pull 4 resultsets from an Oracle stored proc and display the resulting data in four formatted tables, using alternating colors with totals tallying. Does anyone have a sample showing how...
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...
3
by: Pippen | last post by:
I'm currently working with a 10 million plus row database with the data residing on a Unix box with Cache 5.0. The problems is that it can take five days to pull one table from Cache to SQL 2000...
5
by: Julia Baresch | last post by:
Hi everyone, I haven't found any reference to this problem on this group or in Access 97 help. I hope someone here knows this - probably a simple thing, but not obvious. I designed a query to...
2
by: Scott Baird | last post by:
HELP!!! I've got a DB with two tables (relationships with a autonumber). The database works just fine, but I've got a report I simply can't make work. I've made a query that uses data from...
3
by: Rich | last post by:
Hello, I need to pull data from 2 tables that reside on the same sql server but 2 different databases. In Query Analyzer I can say this select t1.*, t2.* from tbl1 t1 join database2.dbo.tbl1...
4
by: sparks | last post by:
We have a new project here, one that I have never tried maybe its easy I don't know yet. We have people that have records dating back over 5 yrs on a sql server. We have to build an access 2003...
6
by: RoomfulExpress | last post by:
Here's the problem that I'm having- I'm trying to pull in 2 fields from my database and place them in the title of the HTML. I'm connecting to the db and selecting everything exactly the same as I am...
5
by: giandeo | last post by:
Hello Experts. Could you find a solution for this problem please! I have the following tables in Access Database Table Name: origin Fields Names: country, countrycode Table Name: make...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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...
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...

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.