好的,我有 mysql 查询,我想在 table_1 中搜索这两个参数
我会尝试用“php”展示这个想法
if(table_2_params.params_id == 124){
//select LIKE "%EXTEC (Sandvik)%" from table_2_params.nosaukums
}
elseif(table_2_params.params_id == 126){
//SELECT FROM table_2_params WHERE nosaukums is BETWEEN "2010" AND "2012"
}
我想查询显示第一个和第二个参数...(他们都匹配)
天我希望你能明白我想说什么...
好的,这是 mysql查询:
SELECT table_1 . * , table_2_params . *
FROM table_1, table_2_params
WHERE table_1.pamat_kat_sad = '756'
AND table_1.preces_id = table_2_params.preces_id
AND (
(
table_2_params.params_id =124
AND table_2_params.nosaukums LIKE "%EXTEC (Sandvik)%"
)
AND (
table_2_params.params_id =126
AND table_2_params.nosaukums
BETWEEN "2010"
AND "2012"
)
)
ORDER BY table_1.preces_id DESC
问题可能是table_2_params.nosaukums
类型是longtext
......
如果我只选择
AND (
table_2_params.params_id =126
AND table_2_params.nosaukums
BETWEEN "2010"
AND "2012"
)
它显示正确的年份......如果我只选择
(
table_2_params.params_id =124
AND table_2_params.nosaukums LIKE "%EXTEC (Sandvik)%"
)
它还显示正确的值...
但我不能让他们俩一起工作..
请帮我!
谢谢!