Question: ```
if($band == "something"){
     $que = "BETWEEN '1000' and '2000'";
}

if($band == "somethingelse"){
     $que = "BETWEEN '2000' and '5000'";
}

if($band == "somethingelseelse"){
     $que = "BETWEEN '5000' and '10000'";
}

if($band == "againsomethingelse"){
     $que = "BETWEEN '10000' and '30000'";
}

$query = mysql_query("SELECT * FROM table WHERE col $que order by datetime desc LIMIT 50");

```

Can't seem to find what i am missing here... I want to make the "between" statement into a php variable so it will change the query items with a given input. there are multiple different inputs for different ranges. when I enter the between manually such as (SELECT \* FROM table WHERE col BETWEEN 1000 AND 2000 order by datetime desc LIMIT 50) I have no problems. it dose not work with the variable
This is my first post here so any help is greatly appreciated!

Answer: 
Relational data is stored in tables. You don't say whether the interior dicts always have the same structure, so for the purposes of this answer I assume they have.

In these circumstances it would be simplest to define a table with three colummns, which I call `name`, `age` and `sex`. The definition would look something like

```
CREATE TABLE t(
    name    VARCHAR(20),
    age     INTEGER,
    sex     CHAR(1))

```

A program to enter your sample data would look something like this:

```
import sqlite3
mydict={'Prem': { 'age': '23' , 'sex': 'male' },
        'Sameer' : { 'age': '22' , 'sex': 'male'}
       } # reformatted to `PEP008` standard, renamed

conn = sqlite3.connect("/tmp/db") # creates a new file if necessary
curs = conn.curs()
for k in mydict:
    curs.execute("""INSERT INTO t (name, age, sex)
                    VALUES (?, ?, ?)""",
                    (k, mydict[k]['age'], mydict[k]['sex'])
conn.commit()

```

This iterates over the keys of `mydict` (I renamed it because `dict`is the name of a built-in type) and inserts the key as `name` and the values of `age` and `sex` from the interior dict.

The `commit()` call is very important - that makes the databases changes permanent!
You need two tables.

First for exmpl Persons:

```
id name
1  Prem  
2  Sameer
...

```

Second stored value:

```
id fk_persons age sex
1  1          23  male
2  2          22  male

```

usualy structure is table for dictionary.