ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SQL Combining Field Results (https://www.excelbanter.com/excel-programming/303415-sql-combining-field-results.html)

ell

SQL Combining Field Results
 
Hi all,

Please forgive me if this is really easy, but I'm from a 4G
background, and not too familar with pure SQL statements.

What I am trying to do is quite simple.

I have two text fields in a record, which I wish to merge at point o
extraction. Ie:

SELECT item-no, desc1, desc2 FROM mytable WHERE mytable.item-no
"MyItem"

To merge the description fields I have tried (for instance):

SELECT desc1 + desc2

But Microsoft Query expects the values as number data.

So I tried:

SELECT desc1 & desc2

and various other permutations, but still have no luck.

Can anyone point me in the right direction please?

Thanks in advance.

El

--
Message posted from http://www.ExcelForum.com


arno

SQL Combining Field Results
 
Hi,

use & instead of +.

eg. Select field1&field2 from mytable

arno



Jamie Collins

SQL Combining Field Results
 
ell wrote ...

To merge the description fields I have tried (for instance):

SELECT desc1 + desc2

But Microsoft Query expects the values as number data.

So I tried:

SELECT desc1 & desc2

and various other permutations, but still have no luck.


Rather than MS Query make the rules, it will be your provider. For
examle, the following works for me when the source is Excel because I
*know* the Jet provider supports the syntax:

SELECT Col1 & Col2 FROM [General$];

What DBMS (data source and provider) are you using?

Jamie.

--

Ell

SQL Combining Field Results
 

"Jamie Collins" wrote in message
om...
ell wrote ...

To merge the description fields I have tried (for instance):

SELECT desc1 + desc2

But Microsoft Query expects the values as number data.

So I tried:

SELECT desc1 & desc2

and various other permutations, but still have no luck.


Rather than MS Query make the rules, it will be your provider. For
examle, the following works for me when the source is Excel because I
*know* the Jet provider supports the syntax:

SELECT Col1 & Col2 FROM [General$];

What DBMS (data source and provider) are you using?

Jamie.


Hi all and thank you very much for your replies so far.

I'm sure I've tried using + and & in various ways, but it seems to throw it
back at me. Both columns are character(30). Nevertheless, I will retry them
as demonstrated by you kind people when I get back into the office tomorrow.

I am querying a SCULPTOR database on a Linux Redhat server, using Transoft
USQL middleware (server and clientside), under Microsoft Excel 2000 Query.

Does Microsoft Query allow full SQL statements and its complete syntax, or
is it known to fail if it can't generate a nice graphical view of your
personalised SQL query?

Thanks again.

Elliot



Jamie Collins

SQL Combining Field Results
 
"Ell" wrote ...

I am querying a SCULPTOR database on a Linux Redhat server, using Transoft
USQL middleware (server and clientside), under Microsoft Excel 2000 Query.

Does Microsoft Query allow full SQL statements and its complete syntax, or
is it known to fail if it can't generate a nice graphical view of your
personalised SQL query?


The wizard seems to write its own version of SQL, which looks awful,
is hard to edit manually and has limitation on OUTER JOINs, alias,
etc. If it can't represent grpahically it tells you but doesn't *fail*
for this reason alone.

If you write your own SQL directly in its SQL window, it is passed to
the provider unamended and executed on the server. I know which one I
prefer...

Jamie.

--


All times are GMT +1. The time now is 09:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com