SQL Select Where Clause doesnt return any result

  • Hi,

    I have a code below which I used select statement to query data from the database, the "WHERE" clause will obtain the range of input from the sheet in column M. When I run this code, there's no error, however, there was no result display either. From trawling in the net, some of the result mentioned that I have to concatenate the input in the column, which I did. But still no result display.


  • It looks like you are using a list of job names, so you need an IN clause, not =


    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • It looks like you are using a list of job names, so you need an IN clause, not =


    Hi Rory,


    Thanks for your help. I tried your solution, but I got invalid procedure call or argument error at job = Left(job, Len(job) - 1)

  • It looks like you are using a list of job names, so you need an IN clause, not =


    I tried again, but now I am getting incorrect syntax error near keyword

  • Sorry forgot the brackets. Should be:


    Code
    1. sql= "SELECT JOB FROM HOUSE WHERE NAME IN (" & Mid$(job, 2) & ")"

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why