I have multiple tables:
order (id,quantity, status, notes, item_id, customer_id)
item (id,number, name)
I have simple program in which in main window I have orders and their statuses(done, pending) that I show on `datagridview`. If I double click on a row, I collect new variable which is basically `order_id` and then I open my order with items ordered in new `datagridview`. But I just can't get right result in second datagridview.
With code bellow I fill my first datagridview
Dim sql As String = "SELECT DISTINCT customer.name, order.status, order.notes, order_items.oder_id FROM ((order INNER JOIN order_items ON order.id = order.items_order_id) INNER JOIN customer ON order.customer_id = customer.id)"
When I double click on a row I get variable `order.id` as integer and then I use it in code bellow.
Dim sql As String = "SELECT item.number, item.name, order.status, order_notes FROM ((order INNER JOIN order_items ON order.id = order_items.order_id) INNER JOIN item ON order_items.item_id = item.id) WHERE (order_items.order_id = " & cellcliked.value & ")"
The items are showing fine (number, name) but the order(status, notes) is the same as first item on my order. For every item that follows on that order. Just cant' get it.