Reputation: 409
how can i make a select from not normed table.
i have the table like this:
this table is not norme BNF 2.
i just want to select the NO_ID where DEPARTEMENT = something.
example:
when the input 44 then NO_ID =1
when the input 37 then NO_ID =3
when the input 13(not in table) then NO_ID = 5
of course when input = 44 it works:
SELECT [NO_ID]
FROM [T_TARIF_ZONE]
WHERE DEPARTEMENT = '44'
but how can i put in WHERE statement when the input = 37 or 13.
thanks you in advance, Stev
Upvotes: 2
Views: 557
Reputation: 18629
Please try:
select
NO_ID,
DEPARTMEMT
from
T
where
' '+DEPARTMEMT+' ' like
(case when @var=13 then ' FRANCE ' ELSE '% '+@var+' %' END)
Upvotes: 1
Reputation: 1864
Oracle version -
SELECT [NO_ID]
FROM [T_TARIF_ZONE]
WHERE INSTR(DEPARTEMENT, '44')>0 OR INSTR(DEPARTEMENT, '37')>0 OR INSTR(DEPARTEMENT, '13')>0
SQL Server version -
SELECT [NO_ID]
FROM [T_TARIF_ZONE]
WHERE PATINDEX('44', DEPARTEMENT)>0 OR PATINDEX('37', DEPARTEMENT)>0 OR PATINDEX('13', DEPARTEMENT)>0
Upvotes: 0
Reputation: 1647
try this:
SELECT [NO_ID]
FROM [T_TARIF_ZONE]
WHERE DEPARTEMENT like '%37%'
Upvotes: 1