0

Just needed a quick help if anyone can provide. I have a column Product_name with unique values in a table named Products.

What I want to do is SELECT each row of this table as a column and then for each row of this resulted query, if their exists a record with that specific transaction_id in a table named Transactiondetails which contains the foreign key from the table Transactions, pull up the quanity.

Table transactiondetails is designed to make the structure of the database in 3rd normal form. For example for a specific transaction id, the number of products and their quantities are all in seperate rows in the table transactiondetails with that specific transaction id.

Now, For example, if I have two products named product A and product B (that means two rows in the table products), then the resulted query should show like this

transaction_id | product A | product B
             1 |         5 |        10

I hope I made it understandable enough.

Any help would be highly appreciated.

4

1 回答 1

0

在 SQL 中,名称“行”和“列”不指视觉呈现(想想“记录”和“属性”),所以这是不可能的,至少在 SQLite 中是不可能的。

如果要在“列”中显示数据,则必须在表示层中进行,而不是在数据层中进行。然后,您将拥有垂直的“行”(“记录”)和水平的“列”(“属性”)。

于 2013-09-01T16:04:46.287 回答