I have got a mysql table structure:
uid company value
Description:
uid -> unical id
company -> four letters code of company ie. AAAA, BIEW
value -> is a code of two different type of data: country or region, where:
country: "/[0-9]+\-/", ie. 49-, character at the end - means this is a region value
region: "/[0-9]+\_[0-9]+/", ie. 49_002 , 49_4, character _ means this is a country value
Now I want to SELECT all records WHICH:
- has a multiple company definitions, ie.
AAAA' OR 'BIEW' - has a multiple country definitions, ie.
'49-' OR '5698-' - first of countries above has specified region. I wan to search
49_01only but not49_03and49_965, which also “belongs” to49-country - second of countries
'5698-'don’t have specified regions and should return only records wherevalue='5698-'
The AAAA company has ‘filter’ that specify country/region records but BIEW has not any specified country/region values. The MYSQL query don’t work properly:
SELECT * FROM `table` WHERE (company='AAAA' OR company='BIEW') AND (value='5698-' OR value='49_01')
If I understand