arushi tomar wrote:Now, what I want to do is, I want to show a table in my webpage with following format:
Roel De Nijs wrote:
I think you have to start with writing the query
arushi tomar wrote:Help with the mysql query would be very much appreciated.
Roel De Nijs wrote:So the first step: which information do you need to retrieve from the database in order to create this table? Once you know which data (columns) you need, you can try writing the query to select this data. So which query do you already write and which issues are you experiencing?
arushi tomar wrote:I have very less experience with mysql queries or even hibernate still I have done a lot of work on those in my project, but this something new, I want to show users vertically and customers horizontally, and show a check box for yes or no according to the mapping.
Roel De Nijs wrote:
That's why we are going back to the basics first.
arushi tomar wrote:I was doing this:
select us.Id, us.userId, cu.companyName FROM USER us INNER JOIN USER_CUSTOMER uc ON us.id = uc.userId INNER JOIN CUSTOMER cu ON cu.id = uc.accountId ORDER by us.id ASC"
arushi tomar wrote:but i want to display it the way i am showing in the question, this simply gave a table with two columns
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Dave Tolls wrote:What does that query give you?
Roel De Nijs wrote:
Nice! That's a very good starting point.
Roel De Nijs wrote:
It will provide a table with 3 columns
Tim Moores wrote:You may also want to check out the DisplayTag library (displaytag.org). It helps a lot with displaying tabular data -especially from a DB- in JSP pages.
arushi tomar wrote:the table it gives me is:
Id User Customer
1 User 1 Customer 1
1 User 1 Customer 2
2 User 2 Customer 3
arushi tomar wrote:Yes, It does give me everything I need. I need the users and customers mapped with each user, which I am getting in my output table, I have added it in the previous reply.
Roel De Nijs wrote:
If I have a look at the mapping table, I'm pretty sure the table would look slightly different: e.g. you would have 4 rows, user1 is linked with customer2 and customer3,...
More importantly you are also missing the users which are not yet linked to a customer (like user4 and user5).
arushi tomar wrote:yes I want to have my final table with all the users and all the customers, so for that I will look into the queries, and check how to get them to my mapping table for further requirements.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |