Experts Round Table Network
Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:
Password:
Remember me
Forgot your password?
Register
need help contructing an SQL stament
Welcome,
Guest
. Please
login
or
register
.
December 03, 2008, 04:01:44 PM
11305
Posts in
1249
Topics by
498
Members
Latest Member:
katCheeme
Home
Help
Search
Login
Register
Experts Round Table Network
|
Databases
|
MySQL
|
need help contructing an SQL stament
« previous
next »
Pages:
[
1
]
Print
Author
Topic: need help contructing an SQL stament (Read 1393 times)
thepreacher
Offline
Posts: 78
need help contructing an SQL stament
«
on:
April 13, 2007, 10:12:10 AM »
I am using MySQL version 4 and i need help in constructing an SQL stament. I need to retrive 3 sets of information from 3 different tables. The tables are Recipient, Customer and Transaction. The relationship is as follows: The customerID can be found in both the Recipient and Transaction tables. The Recipient ID can be found in the Transaction table.
From the recipient table i need firstname, lastname and address. From the Customer table i need the firstname and surname. From the Transaction table i need the transaction date and the transaction amount.
I will be delighted if someone can help. I have never written a mysql join sql comprising more than 2 tables before.
Thanks.
Logged
VGR
Mentor
Offline
Posts: 682
Re: need help contructing an SQL stament
«
Reply #1 on:
April 15, 2007, 12:57:25 AM »
you've all the "billes" to solve the problem yourself ;-)
select c.transaction_date,c.trans_amount,a.firstname,a.lastname,a.address,b.firstname AS cust_fst, b.surname AS cust_surn from transaction AS c LEFT JOIN recipient AS a ON (a.id=c.recipient_id) LEFT JOIN customer AS b ON (b.id=c.cust_id);
your problem lied in :
- assigning ALIASES to tables referenced in a JOIN (MySqld can do this)
- assigning ALIASES to columns being synonyms (firstname and surname, mainly)
Logged
techie overlord, answers all kind of questions on
http://www.europeanexperts.org
Pages:
[
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
ERT 1.5
-----------------------------
=> Round Table Learning Center
=> Bug reports
-----------------------------
Legacy
-----------------------------
=> The next level
=> History of ERT
-----------------------------
Community Affairs
-----------------------------
=> Introductions
=> Ballot Box
===> Closed Polls
=> Soapbox
=> Propose and Consult
===> Propose and Consult...CLOSED
-----------------------------
Bits and Bytes
-----------------------------
=> Tips, Tricks, Snippets, Tidbits And General Pearls Of Wisdom
-----------------------------
Serverside Technology
-----------------------------
=> PHP
=> ASP
-----------------------------
Webservers
-----------------------------
=> Apache
=> IIS
-----------------------------
Databases
-----------------------------
=> MySQL
=> Access
=> MS SQL Server
-----------------------------
Clientside Technology
-----------------------------
=> HTML
=> CSS
=> Javascript
=> Flash
=> WAP/WML
-----------------------------
Web Technologies
-----------------------------
=> General Web Dev
=> Web Standards
=> XML
=> Online Marketing
-----------------------------
Graphics
-----------------------------
=> Graphics Design and Animation
-----------------------------
Programming
-----------------------------
=> .NET
=> JAVA
=> MS DOS Batch Scripting
=> Mathematics
=> C & C++
=> VB
=> Delphi
=> Algorithm design
-----------------------------
Operating Systems
-----------------------------
=> Windows (General)
=> NT Based (2K, 2K-03, NT, XP, Vista)
=> Open Source (All)
-----------------------------
Hardware
-----------------------------
=> Hardware General
=> Gamers Hardware (Advanced)
-----------------------------
Networking
-----------------------------
=> Home (small)
=> Office (large)
=> Internet
-----------------------------
Security
-----------------------------
=> General Security Issues
-----------------------------
Rants/Opinions/Proposals
-----------------------------
=> Site operation
Powered by SMF 1.1 RC2
|
SMF © 2001-2005, Lewis Media
Joomla Bridge by
JoomlaHacks.com