• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Loop through records to display data in Jtable  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day fellow coders.

I am new at coding, I have followed many tutorials but cant find what I am missing, the stupid method: I tried looping through each record of table A once I have the current record then run another select to find what ever data is in table B that matches the table A id.
But I cant get it to work so I abandoned it. The code is too long and the result is messy. See my image I uploaded, I am running it with SQLite, and its should be vry simple but no where do I find sollutions for this issue. Please point me to a place where I can learn how this done.
I have attached an image of my table layout.

Thank you

Mike

jtable_sales.png
[Thumbnail for jtable_sales.png]
 
Bartender
Posts: 5835
56
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mike Oxley wrote:I tried looping through each record of table A once I have the current record then run another select to find what ever data is in table B that matches the table A id.


That's what the  INNER JOIN does.
 
Marshal
Posts: 24468
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However the resulting JTable won't look like the nice picture which Mike posted. It's going to look more like this not-so-nice picture:

+ Mike  + 1 +
+ Mike  + 2 +
+ Mike  + 7 +
+ Mike  + 9 +
+ Carol + 4 +
+ Carol + 5 +
+ Carol + 8 +


It's possible that Mike was complaining about that difference. If that's the case then let me point out that it's possible (with some difficulty) to get the nice version of the JTable but the solution doesn't involve collecting the data in a different way.
 
Mike Oxley
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I agree, ALLOT more work, so has anyone tried doing a query in a record set and add another query inside the While (rs.next).
I NEVER give up so it will work eventually ...lol

What I have tried so far is this and it works for the first query but the second gives an error, trying t solve it but its looking good so far.




The error code is:


It is given on line 46 when the code is not //

But my screen looks awesome so far!

Once i Get it I will post it!
Thank you guys for the efforts.


EDIT: IT works, I forgot the second Recordset next section!
update1.png
[Thumbnail for update1.png]
 
Rancher
Posts: 427
6
Fedora IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So are you asking how to do an inner join or what?
 
get schwifty. tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!