Hey everyone. I'm no expert when it comes to SQL and I'm creating my most complex site to date. I have a very complex query I need to create and I'm not sure what the best method it so reach my goal. I'm going to try and explain my db structure simply without confusing anyone (or myself)(they are a lot bigger than I'm showing here).
id | proptype | nid | price
unl_uap_id | unl_nh_id
uap_id | uap_uid | uap_proptype | uap_price_min | uap_price_max
u_id | u_mobile
Relationships between the tables:
A.proptype <> C.uap_proptype
A.nid <> B.unl_nh_id
B.unl_uap_id <> C.uap_id
C.uap_uid <> D.u_id
What I am trying to do is I am starting at Table A and I need to u_mobile in Table D. (There can be many u_mobile returned)
Comparing A.nid = B.unl_nh_id would return a list of unl_uap_id (many)
Comparing B.unl_uap_id = C.uap_id returns 1 row
Also, I need to ensure that A.proptype = C.uap_proptype AND A.price >= C.uap_price_min AND A.price <= C.uap_price_max
from the list of uap_id I need to find u_mobile from C.uap_id = D.u_id
I'm not sure if I explained that well, but I hope someone can help me out. I started doing nested subqueries, but got lost in my own code. Any help is really appreciated.