1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Excel / MySQL: How to use cells within excel as part of the mysql queries?

Discussion in 'Programming' started by Christian Little, Jun 11, 2008.

  1. #1
    I have an Excel 2007 document that is being used to generate reports from a central MySQL database. Lemmie just make this part clear - the connection works fine, I'm not looking for help on that, the sheet already runs a dozen queries and works great.


    What I want to do though is I have a sheet in the file called CONFIG which has several variables.

    For this purpose, we'll say it's in cell E10 and it's value right now is 100. The value is used to identify a sample size of data to pull from the database.

    Right now the query to MySQL does something along the lines of this:

    
    SELECT {field names omitted} FROM {table name ommitted} ORDER BY RAND() LIMIT 100;
    
    Code (markup):
    Basically it pulls a random sample of 100 records from the database for me to do some statistical analysis.

    But what I want is to change:

    
    LIMIT 100;
    
    Code (markup):
    To:

    
    LIMIT {!'CONFIG':$E$11}
    
    Code (markup):
    But I have no idea how to actually put the cell reference in into the query.

    Can somebody help me on this?

    The goal here is that somebody can simply go to the CONFIG sheet and change the value in E11 to 250 or 1000 or whatever they want to get a different sample size, rather than having to manually change the query that is already built.

    Thanks :)
     
    Christian Little, Jun 11, 2008 IP