Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / September 2004

Tip: Looking for answers? Try searching our database.

sql statement concatenation

Thread view: 
duxbuz - 26 Sep 2004 21:35 GMT
Can anyone point me to some examples of string concatenation in a SELECT
statement.

I want to ask user for values and add to runtime cutom string

Thanks, scoured web can't find any.
IchBin - 27 Sep 2004 00:19 GMT
> Can anyone point me to some examples of string concatenation in a SELECT
> statement.
>
> I want to ask user for values and add to runtime cutom string
>
> Thanks, scoured web can't find any.
Try looking at say MySQL Manual as Ref:
http://dev.mysql.com/doc/mysql/en/SELECT.html

SELECT CONCAT(last_name,', ',first_name) AS full_name
FROM mytable
ORDER BY full_name;

Thanks in Advance...
IchBin
__________________________________________________________________________

'Laughter is inner jogging'
- Norman Cousins, editor and author (1915-1990)
duxbuz - 27 Sep 2004 07:16 GMT
>> Can anyone point me to some examples of string concatenation in a
>> SELECT statement.
[quoted text clipped - 16 lines]
> 'Laughter is inner jogging'
> - Norman Cousins, editor and author (1915-1990)
Am not using MySQL so I thought this would be something java would have
rules  and syntax for perfoming.

Your saying that if I am querying a access database I can use MySQL's
syntax??
IchBin - 27 Sep 2004 09:50 GMT
>>> Can anyone point me to some examples of string concatenation in a
>>> SELECT statement.
[quoted text clipped - 22 lines]
> Your saying that if I am querying a access database I can use MySQL's
> syntax??

Sure, more or less ..  It has been some time since I did VBA SQL calls
in MS's office products. But this was not from java, sorry. But, there
are ansi standards for SQL. Most databases conform to this standard.
This is a database query language and has nothing to do with the
application programming language. You could call it a middleman between
the database and a executing program. Differences are usually extra
functions and procedures that a particular database will have. Some SQL
products do not conform to SQL standard to 100%. My feeling is that this
occurs only when you start to do complex SQL Queries.

You can easily *goggle* for *MS Access Databases* and get a ton of hits.
Go to Microsoft and do a search in here technical forums for access. Ex.
http://office.microsoft.com/en-us/FX010857911033.aspx

Or do a *goggle* search in the newsgroups. Also there are newsgroups for
MS access. Or naturally the book that comes with Access.

What I use to do when I did have a lot of Internet access was to go to a
book store and just read what I needed to know.

Not sure how technical you want to get...
Signature


Hope this helps...
IchBin
__________________________________________________________________________

'Laughter is inner jogging'
- Norman Cousins, editor and author (1915-1990)

duxbuz - 28 Sep 2004 07:26 GMT
>>>> Can anyone point me to some examples of string concatenation in a
>>>> SELECT statement.
[quoted text clipped - 44 lines]
>
> Not sure how technical you want to get...
Thanks Ich Bin,

I am going to look for a solution, although have been looking fo two
days now.

My sql statement woul be something like this:
ResultSet rs = stmt.executeQuery("SELECT Variable1, Variable2 FROM
Variable3");

Just so you know what i am on about. I was trying stuff like this:
"SELECT" + Variable1 + "," + Variable2 + "FROM" +Variable3);

Anyway thanks for responses.
IchBin - 28 Sep 2004 10:46 GMT
>>>>> Can anyone point me to some examples of string concatenation in a
>>>>> SELECT statement.
[quoted text clipped - 56 lines]
> Just so you know what i am on about. I was trying stuff like this:
> "SELECT" + Variable1 + "," + Variable2 + "FROM" +Variable3);

It looks ok except that "FROM" should be " FROM " and "SELECT" should be
"SELECT ".

Now I understand when you say concat.!

Don't confuse SQL and the way that you concate a java string statement
that will be executed by the SQL preprocessor.

> Anyway thanks for responses.

Think you want to try:

String sqlStatement = "SELECT " + Variable1 + "," + Variable2 + " FROM "
+ Variable3);
ResultSet rs = stmt.executeQuery(sqlStatement);

Reason: Just for debugging. If you want to trace and look at the
sqlStatement and how it was built.

Signature

Hope this is a little better help...
IchBin
__________________________________________________________________________

'Laughter is inner jogging'
- Norman Cousins, editor and author (1915-1990)



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.