MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 21st, 2013, 11:34 AM
bstar bstar is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 13 bstar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 55 m 24 sec
Reputation Power: 0
Display problems

I am trying to do a query that displays the customer name with the "customer" label. Here's what I've done so far:

SELECT a.account_id, a.cust_id, a.last_activity_date, a.open_emp_id,
CONCAT(e.fname, ' ', e.lname) as Opened_by, a.avail_balance
FROM account a INNER JOIN employee e
ON a.open_emp_id = e. emp_id
CONCAT (i.fname, i.lname, b.name) AS Customer
FROM individual i INNER JOIN business b
on b.cust_id = i.cust_id
WHERE NOT EXISTS (SELECT 1
FROM transaction t
WHERE t.txn_date = a.last_activity_date);

I got this error message:

Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONCAT (i.fname, i.lname, b.name) AS Customer
FROM individual i INNER JOIN busin' at line 5

It had been working great until I added the 2nd CONCAT & INNER JOIN.

Thanks in advance for helping someone who's still learning.

Reply With Quote
  #2  
Old February 21st, 2013, 12:14 PM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,873 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 2 h 24 m 6 sec
Reputation Power: 813
Hi,

I don't have the slightest idea what you're trying to do. What is this "2nd CONCAT & INNER JOIN" supposed to do?

In any case, the second CONCAT makes no sense in this context, and you cannot have multiple "FROM" and "WHERE" for a single query.

Reply With Quote
  #3  
Old March 7th, 2013, 01:16 PM
Techanalyst Techanalyst is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 11 Techanalyst User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 32 m 26 sec
Reputation Power: 0
how the result table looks like?

Reply With Quote
  #4  
Old March 7th, 2013, 02:28 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,375 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 7 h 30 m 16 sec
Reputation Power: 4140
Quote:
Originally Posted by bstar
It had been working great until I added the 2nd CONCAT & INNER JOIN.
there is only one SELECT clause in any query, and only one FROM clause

you can't just patch on some new columns and a new FROM clause to an existing query

your first two tables, a nd e, are properly joined, and your second two tables, i and b, are also properly joined, but you will need either to set up two SELECTs in a UNION, or else find some way to logically connect a/e to i/b
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Display problems

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap