mysql - How to select code from database -


i hava database codes

indirect customer cust-code nursing home nh000001 dentist dn000001 other ot000001

and direct customer cust-code nursing home nh050001 dentist dn050001 other ot050001

note after nh there 00 indirect customer , 05 direct customers

i need write query list of direct , indirect customer

select * bmwregistration ,corporation_data_entity,category_data_entity,ward_data_entity                 occu_corp_id='$corpo'                          , occu_division = '$divi'                  , bmwregistration.occu_corp_id = corporation_data_entity.corp_id                  , bmwregistration.occu_ward = ward_data_entity.ward_id                 , (cust_code '%bb00%'                  or cust_code '%dp00%'                  or cust_code '%nh00%'                  or cust_code '%pl00%'                  or cust_code '%dn00%'                  or cust_code '%ot00%'                  or cust_code '%pd00%'                  or cust_code '%pn00%' )  

when executing above query shows 1 row 8 times same cust-code. can use group clause? wrong query?

it select rows same customer code in 8 consecutive lines cust-code

1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3( 8 times same row cust_id 3) 

try group by

   select * bmwregistration ,corporation_data_entity,category_data_entity,ward_data_entity             occu_corp_id='$corpo'                      , occu_division = '$divi'              , bmwregistration.occu_corp_id = corporation_data_entity.corp_id              , bmwregistration.occu_ward = ward_data_entity.ward_id             , (cust_code '%bb00%'              or cust_code '%dp00%'              or cust_code '%nh00%'              or cust_code '%pl00%'              or cust_code '%dn00%'              or cust_code '%ot00%'              or cust_code '%pd00%'              or cust_code '%pn00%' )        group  bmwregistration 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -