How to assign the value of an Excel column in an SQL command

Asked

Viewed 3,105 times

0

I was able to connect to my Mysql Database via ODBC, and display the information I need via SQL command, but I would like the contents of a particular cell of my spreadsheet to be in this SQL query, so I can:

inserir a descrição da imagem aqui

Display only the client name according to the so-called "1016762", what I would like is for the sql command to look something like this:

SELECT customer_id FROM `otrs`.`ticket` where `tn` = A7

Where A7 would be the cell of the spreadsheet where it would contain the same value of "1016762", but for what I researched I would have to pass it by the parameters button, but it is not enabled for me

  • In the Excel data tab select other sources and then From Microsoft Query. There you will be able to assemble a query identical to those made in MS Access and reference the parameters in the desired cells.

  • When you do the query in Microsoft Query, you have to put a filter in some column, this filter, if I’m not mistaken should be for example codigo[] and then when you close the query, this screen of your print will be shown with the button parâmetros... activated. Then just choose the cell with the value. I put an answer here would be like a tutorial with multiple prints and this does not look cool on the site.

  • And why would you consider that a bad thing? I believe that it would be much easier even for the next ones who have this same doubt, to understand how to solve the problem

  • I will prepare and answer today.

  • Just for the record, I was able to create the connection but the "Parameters" button in "Connection properties" always appears disabled. I don’t know if that’s where I can assign excel cell values in the sql query

1 answer

0


I was able to release the Parameter in Properties of the connection changing my SQL command to this:

SELECT customer_id FROM `otrs`.`ticket` where (tn = ?)

So when trying to execute the command a window is opened to request the parameter that will be used in the Query

I found this tip on this forum

  • When you open the connection properties, and then the parameters button, you have an option which is to get the cell value. Including an option to update when changing the cell.

  • Yes, but to enable the "Parameters" button it is necessary that in the Query be with one of the items with ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.