Python Forum

Full Version: How to display multiple data(from 2 different related table) in one cell of QTableWid
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
There are 2 related tables in db.

One order_ID(table1) is mapped with multiple values prod, quantity and rate. One to Many relationship. I want to display all these values in one common table.

table 1:
order_ID date buyer ship_chr total_price
001 01/01 abc 15 240
002 05/01 xyz 10 235

table 2:
order_ID product quantity rate
001 pen 50 2
001 paper 25 1
001 pin 50 2
002 paper 25 1
002 pen 100 2

I want to display all values in one row, so all multiple values should be displayed in one cell only. So, how to display multiple values of prod, quantity and rate corresponding to one orderID?

OrderID Date Buyer Prod Quantity Rate Shipping Total
001 01/01 abc pen 50 2 15 240
paper 25 1
pin 50 2
002 05/01 xyz paper 25 1 10 235
pen 100 2
Output:
table 1: order_ID date buyer ship_chr total_price 001 01/01 abc 15 240 002 05/01 xyz 10 235 table 2: order_ID product quantity rate 001 pen 50 2 001 paper 25 1 001 pin 50 2 002 paper 25 1 002 pen 100 2 I want to display in QTableWidget like this: OrderID Date Buyer Prod Quantity Rate Shipping Total 001 01/01 abc pen 50 2 15 240 paper 25 1 pin 50 2 002 05/01 xyz paper 25 1 10 235 pen 100 2
Is there a python question here? Looks like pure SQL. (look into views by the way)
@Larz60+
This question is related to pyqt5. I want to display table 3 in QTableWidget component of PqQT5.
Main issue is how to display multiple values in one cell of QTableWidget
I see it in the header now. Sometimes I glance over the header, which is what I did here.
I'm not a big user of Qt (although I will be soon out of necessity), so will leave this for other moderators.