I have 2 tables like this:
Table 1
-------
ID
score
Table 2
-------
ID
score_from
score_to
How do I get ID from Table 2, if I have score=’12’ in Table1 based on score_from and score_to in Table 2 ?
Contents of Table1:
----------------------
ID |Score |
----------------------
1 |12 |
----------------------
2 |40 |
----------------------
Contents of Table2:
------------------------------
ID |score_from|score_to|
------------------------------
1 |0 |20 |
------------------------------
2 |21 |40 |
------------------------------
If I have score=’12’ from table1, how can I write a query to get ID=’1′ in table2?
Try this one,
SQLFiddle Demo
or if you want only the
IDSQLFiddle Demo