Get DB data at JQuery onchange textfield
I have confused how to deciding the way what I would take in MySQL.
I have 4 textfield:
<input type="text" id="model">
<input type="text开发者_JAVA技巧" id="number">
<input type="text" id="line">
<input type="text" id="date">
then a Table in DB Detail_model
:
+---------+-----+-----------+-------------+-----------+
|Model |Line |Date |Startnumber |Endnumber |
+---------+-----+-----------+-------------+-----------+
|Bear |X01 |2013-04-26 |098X0001 |098X0100 |
|Cat |X02 |2013-03-10 |098x0201 |098X0300 |
+---------+-----+-----------+-------------+-----------+
If I type Cat
at id=model and 098x0003
at id=number, I would get result :
Model Line Date
Cat X02 2013-03-10
its means during onchange I send parameter Cat
and 098X0003
into MYSQL Query.
TRY:
SELECT Model,Line, Date FROM Detail_model
WHERE Model LIKE 'Cat' AND .......(How to filter the number) ?
If startnumber and endnumber are integers you could select like that:
SELECT A.name,B.class, B.address FROM tableA AS A
LEFT JOIN tableB AS B
ON A.name = B.name
WHERE a.number >= b.startnumber AND a.number <= b.endnumber
SELECT Model,Line, Date FROM Detail_model
WHERE Model LIKE 'Cat' AND Startnumber <= '098x0003' AND Endnumber >= '098X0003'
This is what I get and I get the result.
精彩评论