php - Confused in mysql query -


i have 2 tables property_description , property_extras.

table property_description looks like

id location price etc etc 1  new york 3000   v    v 

table property_extras looks like

property_id  extras 1           12,14,16,167 

well question how should mysql query return result if @ least 1 of extras matched ?

you should ideally have extras normalized like

property_id  extra_id 1            12 1            14 ... 

if can't convert database structure this, have (terrible) like:

select property_id property_extras     extras '12,%' or extras '%,12,%' or  extras '%,12' 

or, if can insert commas start , end ,12,14,..., delphist points out, simply:

select property_id property_extras extras '%,12,%' 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -