Forums Register Login

Making an SQL query string and using Index

+Pie Number of slices to send: Send
I was stumbling along and getting index errors while trying to write a string variable that contained the SQL query I wanted and then using the Index method to try to pull the data out.
I found in my string I needed those spaces after the words and that it was nice to place a comma before a word(column name) just as I would write the query as I do on the mainframe.
Using INDEXING to pull the data from the results to variables in the Java code was not completely clear to me. I was unsure if the index was to the order in the table and if the index started with 0 or 1.
From playing around it seems the index is to the order that the select SQL statement is written and not the table itself. Between the index thing and being careful to put spaces and commas in the string for the SQL statement I got a lot of trial and error. I still may have something wrong but it works now. I welcome any comments of syntax style or any other suggestion.



SQL-style-and-INDEX.jpg
[Thumbnail for SQL-style-and-INDEX.jpg]
+Pie Number of slices to send: Send
In the future, please post code using code tags (see UseCodeTags). Screen shots are OK, but include the code as text as well.

Rod Hittle wrote:I was unsure if the index was to the order in the table and if the index started with 0 or 1.


JDBC indexes start with 1, and are the order in the select statement. Why not use the column names rather than indexes?

Between the index thing and being careful to put spaces and commas in the string for the SQL statement I got a lot of trial and error.


Yes the SQL statement must follow correct syntax; just like any programming language.
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 592 times.
Similar Threads
Program i need help bad
Advice on Data Base for newbie : Should I take the MySQL exam ?
self study for 1Z0-882 - Oracle Certified Professional, MySQL 5.6 Developer
SQL Performance Tuning - Release Announcement - Addison-Wesley
strings
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:33:35.