Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

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


Report this thread to moderator Post Follow-up to this message
Old Post
cvillard
08-23-05 01:23 AM


Re: Pull data from Two tables
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.


Report this thread to moderator Post Follow-up to this message
Old Post
--CELKO--
08-23-05 01:23 AM


Re: Pull data from Two tables
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.


Report this thread to moderator Post Follow-up to this message
Old Post
cvillard
08-23-05 01:23 AM


Re: Pull data from Two tables
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.[UserN
ame]

--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


Report this thread to moderator Post Follow-up to this message
Old Post
Stu
08-23-05 01:23 AM


Re: Pull data from Two tables
"cvillard" <cvillard@gmail.com> wrote in message
news:1124752154.644452.160570@f14g2000cwb.googlegroups.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.
>



Report this thread to moderator Post Follow-up to this message
Old Post
Greg D. Moore \(Strider\)
08-23-05 01:23 AM


Re: Pull data from Two tables
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


Report this thread to moderator Post Follow-up to this message
Old Post
cvillard
08-23-05 01:23 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 12:07 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006