Dave
Dave

Reputation: 87

SELECT query wtih three tables not going through

I have problem with SELECT query from multiple tables. I have three tables customer, order and job and I wan't to use select query to fill dataset and with it datagridview.

Dim sql As String = "SELECT customer.name, order.date_taken, order.status, job.realisation FROM customer INNER JOIN order ON customer.id = order.id_customer "

Code is working fine select query is without job.realisation.

In my form I have dropdownlist populated from job.realisation table.In job table I have only ID and realisation columns(realisation as string), but I dont have id_job key in my order table as I'm populating dropwdownlist with items from job.realisation. The thing is that I will like to populate datagridview with SELECT statement above and then add checkboxes on all job.realisiation items that my order contains.

[Customer] [OrderDate] [job.realistion1] [job.realistion2] [job.realistion3] 

  ADAM      23.1.2013          x                                   x
  GREG      23.1.2013     

Upvotes: 0

Views: 155

Answers (1)

John Woo
John Woo

Reputation: 263723

then you need to join the table job on your query,

SELECT  customer.name, 
        order.date_taken, 
        order.status, 
        job.realisation 
FROM    customer 
        INNER JOIN order 
            ON customer.id = order.id_customer
        INNER JOIN job
            ON [tableName].[columnName] = job.[columnName]

just change the values of [tableName] and [columnName] to your orignal table name and column name.

Upvotes: 1

Related Questions