If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL - Combining Fields

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-30-05, 19:49
Mark Gambo Mark Gambo is offline
Registered User
 
Join Date: May 2003
Location: New York, NY
Posts: 225
MySQL - Combining Fields

Why is it when I run this SQL String against a MS SQL db it works fine:

Code:
"SELECT USERLNAM + ' ' + USERFNAM + ' ' + Title, USRNUM "
FROM USER_TABLE;"
But when I run it against a MySQL DB I get a zero value for the "USERLNAM + ' ' + USERFNAM + ' ' + Title".

if I run the following SQL String against the MySQL DB it works fine:


Code:
"SELECT USERLNAM, USRNUM "
FROM USER_TABLE;"
How do I write this SQL String so that is works with both DB?

I am using ADO and VB6 to connect to both DB.
Reply With Quote
  #2 (permalink)  
Old 09-30-05, 19:50
Mark Gambo Mark Gambo is offline
Registered User
 
Join Date: May 2003
Location: New York, NY
Posts: 225
think I found the answer to my question the CONCAT Function

Code:
"SELECT CONCAT(USERLNAM, ', ', USERFNAM, ', ', Title), USRNUM "
FROM USER_TABLE;"
But I don't have a MS SQL DB available to check and see if this function willl work with it. Can anyone advise?
Reply With Quote
  #3 (permalink)  
Old 09-30-05, 19:52
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
you cannot use the same sql statement on both of those database systems

they are just flat out not syntax compatible for concatenation
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 09-30-05, 20:11
Mark Gambo Mark Gambo is offline
Registered User
 
Join Date: May 2003
Location: New York, NY
Posts: 225
Thanks Rudy!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On