[VIEWED 12325
TIMES]
|
SAVE! for ease of future access.
|
|
|
virusno1
Please log in to subscribe to virusno1's postings.
Posted on 11-16-15 1:04
PM [Snapshot: 28]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
First of all, I am not sure why there is an emailaddress in Address table. That's just bad table design. That just violates normal form of DB design and you will end up storing tons of redundant data. If possible redesign your table like this Customers- contains customerid,First name last name, emailaddress Address- Contains addressid,City State, zipcode customeraddressBridge- customerid and addressid Then Select C.FirstName, C.LastName,A.City,A.State,A.Zipcode From Customer C join customeraddressBridge CAB on CAB.CustomerID=C.CustomerID join Address A on A.AddressID=CAB.AddressID If this is not what you are looking for then give some example what you are looking for. It's not very clear from your question.
|
|
|
|
virusno1
Please log in to subscribe to virusno1's postings.
Posted on 11-16-15 1:11
PM [Snapshot: 40]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Wait a second, Does your Address table really contains EmailAddress field? I hope not. If that's the case I really don't know what are you trying to do because you completely screwed up the entire query. Basically what you are doing is you are not joining two tables, you are joining a table with same table with Email address. So of course you will get all the emailaddress from customers. I am pretty much sure you didn't build those table according to your level of writing queries. Do you really understand the join? If not stop what you are doing and study join first because it looks like what you are asking is completely messed up.
|
|
|
cp21
Please log in to subscribe to cp21's postings.
Posted on 11-16-15 1:20
PM [Snapshot: 70]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
I have to join both tables. And No, Addresses does have have email address. Addresses contains their physical addresses. Customers has their email and such. I need to return listed columns along with one row for each address for the customer with an email address of abcde@abc.com
|
|
|
virusno1
Please log in to subscribe to virusno1's postings.
Posted on 11-16-15 1:30
PM [Snapshot: 86]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
lol, ok Then why are you joining a table which can not be joined? Now I know what's your problem is. There must be a table which has a mapping between your customer table and address table in your database. Find that table and above query i.e Select C.FirstName, C.LastName,A.City,A.State,A.Zipcode From Customer C join customeraddressBridge CAB on CAB.CustomerID=C.CustomerID join Address A on A.AddressID=CAB.AddressID You are completely missing key table which is a bridge or mapping table
|
|
|
bairaghi
Please log in to subscribe to bairaghi's postings.
Posted on 11-16-15 3:08
PM [Snapshot: 165]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
@cp21 if u need IT help, u know where to turn. DANG !!!
|
|
|
cp21
Please log in to subscribe to cp21's postings.
Posted on 11-16-15 3:32
PM [Snapshot: 187]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
|
|
|
bairaghi
Please log in to subscribe to bairaghi's postings.
Posted on 11-16-15 3:34
PM [Snapshot: 189]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
|
|
|
cp21
Please log in to subscribe to cp21's postings.
Posted on 11-16-15 3:57
PM [Snapshot: 207]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
he said he is too busy marinating some meat poles with his mouth.
|
|
|
bairaghi
Please log in to subscribe to bairaghi's postings.
Posted on 11-16-15 3:59
PM [Snapshot: 209]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
LOL no offense, was just joking.
|
|
|
cp21
Please log in to subscribe to cp21's postings.
Posted on 11-16-15 4:26
PM [Snapshot: 244]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
|
|
|
prankster
Please log in to subscribe to prankster's postings.
Posted on 11-17-15 10:21
AM [Snapshot: 395]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Lets, see if you are trying to do following, Customer_table -------------------- Customer_Id | Customer_Name | Customer_City | Customer_State Email_Id_table ------------------ Customer_Id | Customer_Email_Id Select C.Customer_Id, C.Customer_Name, C.Customer_City, C.Customer_State, E.Customer_Email_id From Customer_table C Join Email_Id_talbe E on C.Customer_Id = E.Customer_Id Here is the sqlfiddle, http://sqlfiddle.com/#!6/655f9/4
|
|
|
SolveSQL
Please log in to subscribe to SolveSQL's postings.
Posted on 11-17-15 10:39
AM [Snapshot: 408]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Try this... SELECT Name,City,State--,(add more cols as needed) FROM ADDRESS a --(assuming thats your table name) JOIN customer c ON a.customerid= c.customerid --(assuming customer is the table name and customerid is the common column) WHERE c.emailaddress = 'abcde@abc.com' --(assuming emailaddress is the column that has email for the customer)
Last edited: 17-Nov-15 10:40 AM
|
|
|
NepaliBhai
Please log in to subscribe to NepaliBhai's postings.
Posted on 11-17-15 11:12
AM [Snapshot: 423]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Last edited: 17-Nov-15 11:53 AM
|
|
|
NepaliBhai
Please log in to subscribe to NepaliBhai's postings.
Posted on 11-17-15 11:12
AM [Snapshot: 423]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Last edited: 17-Nov-15 11:54 AM
|
|
|
SolveSQL
Please log in to subscribe to SolveSQL's postings.
Posted on 11-17-15 12:03
PM [Snapshot: 486]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
"This statement doesn't return anything." does it error out....i dont think it would. replace your last line with... Where rtrim(ltrim(c.emailaddress)) = 'allen.sherwood@yahoo.com'
Last edited: 17-Nov-15 12:03 PM
|
|
|
cp21
Please log in to subscribe to cp21's postings.
Posted on 11-17-15 12:11
PM [Snapshot: 499]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Doesn't show any error, it compiles, but doesn't show any results.
|
|
|
SolveSQL
Please log in to subscribe to SolveSQL's postings.
Posted on 11-17-15 12:52
PM [Snapshot: 533]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
use the trim logic in the on clause as well.
|
|
|
SolveSQL
Please log in to subscribe to SolveSQL's postings.
Posted on 11-17-15 1:00
PM [Snapshot: 537]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
you have the email address misspelled.....its "allan" not "allen"! use copy paste option...limits human error!
|
|
|
cp21
Please log in to subscribe to cp21's postings.
Posted on 11-17-15 1:11
PM [Snapshot: 567]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
|
|
|
prankster
Please log in to subscribe to prankster's postings.
Posted on 11-17-15 1:16
PM [Snapshot: 575]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
With small difference, http://sqlfiddle.com/#!6/433b6/8
|
|
|